mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-02-13 03:21:37 +00:00
DRY principle
This commit is contained in:
parent
5527a18c5c
commit
458096a743
@ -155,31 +155,10 @@ public static partial class ManagedConfiguration
|
||||
LuaTable settings,
|
||||
bool dryRun)
|
||||
{
|
||||
//
|
||||
// Handle configured string values
|
||||
//
|
||||
|
||||
// Check if that configuration was registered:
|
||||
if(!TryGet(configSelection, propertyExpression, out var configMeta))
|
||||
return false;
|
||||
|
||||
var successful = false;
|
||||
var configuredValue = configMeta.Default;
|
||||
|
||||
// Step 1 -- try to read the Lua value out of the Lua table:
|
||||
if(settings.TryGetValue(SettingsManager.ToSettingName(propertyExpression), out var configuredTextValue))
|
||||
{
|
||||
// Step 2 -- try to read the Lua value as a string:
|
||||
if(configuredTextValue.TryRead<string>(out var configuredText))
|
||||
{
|
||||
configuredValue = configuredText;
|
||||
successful = true;
|
||||
}
|
||||
}
|
||||
|
||||
return HandleParsedValue(configPluginId, dryRun, successful, configMeta, configuredValue);
|
||||
return TryProcessConfiguration(configSelection, propertyExpression, string.Empty, configPluginId, settings,
|
||||
dryRun);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to process the configuration settings from a Lua table for string values.
|
||||
/// </summary>
|
||||
@ -188,12 +167,14 @@ public static partial class ManagedConfiguration
|
||||
/// Furthermore, it locks the managed state of the configuration metadata to the provided configuration plugin ID.
|
||||
/// The setting's value is set to the configured value.
|
||||
/// </remarks>
|
||||
/// <param name="type">Parameter type of the configuration entry.</param>
|
||||
/// <param name="configPluginId">The ID of the related configuration plugin.</param>
|
||||
/// <param name="settings">The Lua table containing the settings to process.</param>
|
||||
/// <param name="configSelection">The expression to select the configuration class.</param>
|
||||
/// <param name="propertyExpression">The expression to select the property within the configuration class.</param>
|
||||
/// <param name="dryRun">When true, the method will not apply any changes, but only check if the configuration can be read.</param>
|
||||
/// <typeparam name="TClass">The type of the configuration class.</typeparam>
|
||||
/// <typeparam name="TDataType">The data type of the configuration.</typeparam>
|
||||
/// <returns>True when the configuration was successfully processed, otherwise false.</returns>
|
||||
public static bool TryProcessConfiguration<TClass, TDataType>(
|
||||
Expression<Func<Data, TClass>> configSelection,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user