diff --git a/app/MindWork AI Studio/Settings/ManagedConfiguration.Parsing.cs b/app/MindWork AI Studio/Settings/ManagedConfiguration.Parsing.cs index d62d477c..a475937e 100644 --- a/app/MindWork AI Studio/Settings/ManagedConfiguration.Parsing.cs +++ b/app/MindWork AI Studio/Settings/ManagedConfiguration.Parsing.cs @@ -622,7 +622,7 @@ public static partial class ManagedConfiguration /// True when the configuration was successfully processed, otherwise false. public static bool TryProcessConfiguration( Expression> configSelection, - Expression>> propertyExpression, + Expression>> propertyExpression, Guid configPluginId, LuaTable settings, bool dryRun) @@ -646,7 +646,8 @@ public static partial class ManagedConfiguration // Determine the length of the Lua table and prepare a dictionary to hold the parsed key-value pairs. // Instead of using ArrayLength, we use HashMapCount to get the number of key-value pairs: var len = valueTable.HashMapCount; - var dict = new Dictionary(len); + if (len > 0) + configuredValue.Clear(); // In order to iterate over all key-value pairs in the Lua table, we have to use TryGetNext. // Thus, we initialize the previous key variable to Nil and keep calling TryGetNext until @@ -663,10 +664,9 @@ public static partial class ManagedConfiguration // If both key and value were read successfully, add them to the dictionary: if (hadKey && hadValue) - dict[key] = value; + configuredValue[key] = value; } - configuredValue = dict; successful = true; } diff --git a/app/MindWork AI Studio/Settings/ManagedConfiguration.Register.cs b/app/MindWork AI Studio/Settings/ManagedConfiguration.Register.cs index bdd3c4c4..fbc33767 100644 --- a/app/MindWork AI Studio/Settings/ManagedConfiguration.Register.cs +++ b/app/MindWork AI Studio/Settings/ManagedConfiguration.Register.cs @@ -232,7 +232,7 @@ public static partial class ManagedConfiguration return [..defaultValues]; } - + /// /// Registers a configuration setting with a default dictionary of string key-value pairs. /// @@ -244,16 +244,18 @@ public static partial class ManagedConfiguration /// The expression to select the property within the configuration class. /// The default dictionary of values to use when the setting is not configured. /// The type of the configuration class from which the property is selected. + /// >The type of the dictionary within the configuration class. /// A dictionary containing the default values. - public static Dictionary Register( + public static TDict Register( Expression>? configSelection, - Expression>> propertyExpression, - Dictionary defaultValues) + Expression>> propertyExpression, + TDict defaultValues) + where TDict : IDictionary, new() { // When called from the JSON deserializer by using the standard constructor, // we ignore the register call and return the default value: if (configSelection is null) - return []; + return new(); var configPath = Path(configSelection, propertyExpression); @@ -262,7 +264,7 @@ public static partial class ManagedConfiguration return defaultValues; // Not registered yet, so we register it now: - METADATA[configPath] = new ConfigMeta>(configSelection, propertyExpression) + METADATA[configPath] = new ConfigMeta>(configSelection, propertyExpression) { Default = defaultValues, };