diff --git a/app/MindWork AI Studio/Settings/ManagedConfiguration.cs b/app/MindWork AI Studio/Settings/ManagedConfiguration.cs index cdcfdd78..04f73983 100644 --- a/app/MindWork AI Studio/Settings/ManagedConfiguration.cs +++ b/app/MindWork AI Studio/Settings/ManagedConfiguration.cs @@ -11,19 +11,26 @@ public static partial class ManagedConfiguration private static readonly ConcurrentDictionary METADATA = new(); /// - /// Attempts to retrieve the configuration metadata for a given configuration selection and property expression. + /// Attempts to retrieve the configuration metadata for a given configuration selection and + /// property expression. /// /// - /// When no configuration metadata is found, it returns a NoConfig instance with the default value set to default(TValue). - /// This allows the caller to handle the absence of configuration gracefully. In such cases, the return value of the method will be false. + /// When no configuration metadata is found, it returns a NoConfig instance with the default + /// value set to default(TValue). This allows the caller to handle the absence of configuration + /// gracefully. In such cases, the return value of the method will be false. /// /// The expression to select the configuration class. - /// The expression to select the property within the configuration class. - /// The output parameter that will hold the configuration metadata if found. + /// The expression to select the property within the + /// configuration class. + /// The output parameter that will hold the configuration metadata + /// if found. /// The type of the configuration class. /// The type of the property within the configuration class. /// True if the configuration metadata was found, otherwise false. - public static bool TryGet(Expression> configSelection, Expression> propertyExpression, out ConfigMeta configMeta) + public static bool TryGet( + Expression> configSelection, + Expression> propertyExpression, + out ConfigMeta configMeta) { var configPath = Path(configSelection, propertyExpression); if (METADATA.TryGetValue(configPath, out var value) && value is ConfigMeta meta) @@ -40,6 +47,110 @@ public static partial class ManagedConfiguration return false; } + /// + /// Attempts to retrieve the configuration metadata for a list-based setting. + /// + /// + /// When no configuration metadata is found, it returns a NoConfig instance with the default + /// value set to an empty list. This allows the caller to handle the absence of configuration + /// gracefully. In such cases, the return value of the method will be false. + /// + /// The expression to select the configuration class. + /// The expression to select the property within the + /// configuration class. + /// The output parameter that will hold the configuration metadata + /// if found. + /// The type of the configuration class. + /// The type of the property within the configuration class. + /// True if the configuration metadata was found, otherwise false. + public static bool TryGet( + Expression> configSelection, + Expression>> propertyExpression, + out ConfigMeta> configMeta) + { + var configPath = Path(configSelection, propertyExpression); + if (METADATA.TryGetValue(configPath, out var value) && value is ConfigMeta> meta) + { + configMeta = meta; + return true; + } + + configMeta = new NoConfig>(configSelection, propertyExpression) + { + Default = [], + }; + return false; + } + + /// + /// Attempts to retrieve the configuration metadata for a set-based setting. + /// + /// + /// When no configuration metadata is found, it returns a NoConfig instance with the default + /// value set to an empty set. This allows the caller to handle the absence of configuration + /// gracefully. In such cases, the return value of the method will be false. + /// + /// The expression to select the configuration class. + /// The expression to select the property within the + /// configuration class. + /// The output parameter that will hold the configuration metadata + /// if found. + /// The type of the configuration class. + /// The type of the property within the configuration class. + /// True if the configuration metadata was found, otherwise false. + public static bool TryGet( + Expression> configSelection, + Expression>> propertyExpression, + out ConfigMeta> configMeta) + { + var configPath = Path(configSelection, propertyExpression); + if (METADATA.TryGetValue(configPath, out var value) && value is ConfigMeta> meta) + { + configMeta = meta; + return true; + } + + configMeta = new NoConfig>(configSelection, propertyExpression) + { + Default = new HashSet(), + }; + return false; + } + + /// + /// Attempts to retrieve the configuration metadata for a string dictionary-based setting. + /// + /// + /// When no configuration metadata is found, it returns a NoConfig instance with the default + /// value set to an empty dictionary. This allows the caller to handle the absence of configuration + /// gracefully. In such cases, the return value of the method will be false. + /// + /// The expression to select the configuration class. + /// The expression to select the property within the + /// configuration class. + /// The output parameter that will hold the configuration metadata + /// if found. + /// The type of the configuration class. + /// True if the configuration metadata was found, otherwise false. + public static bool TryGet( + Expression> configSelection, + Expression>> propertyExpression, + out ConfigMeta> configMeta) + { + var configPath = Path(configSelection, propertyExpression); + if (METADATA.TryGetValue(configPath, out var value) && value is ConfigMeta> meta) + { + configMeta = meta; + return true; + } + + configMeta = new NoConfig>(configSelection, propertyExpression) + { + Default = [], + }; + return false; + } + /// /// Checks if a configuration setting is left over from a configuration plugin that is no longer available. /// If the configuration setting is locked and managed by a configuration plugin that is not available,