mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-02-15 08:21:37 +00:00
DRY principle
This commit is contained in:
parent
5527a18c5c
commit
458096a743
@ -155,29 +155,8 @@ public static partial class ManagedConfiguration
|
|||||||
LuaTable settings,
|
LuaTable settings,
|
||||||
bool dryRun)
|
bool dryRun)
|
||||||
{
|
{
|
||||||
//
|
return TryProcessConfiguration(configSelection, propertyExpression, string.Empty, configPluginId, settings,
|
||||||
// Handle configured string values
|
dryRun);
|
||||||
//
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <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.
|
/// 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.
|
/// The setting's value is set to the configured value.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
|
/// <param name="type">Parameter type of the configuration entry.</param>
|
||||||
/// <param name="configPluginId">The ID of the related configuration plugin.</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="settings">The Lua table containing the settings to process.</param>
|
||||||
/// <param name="configSelection">The expression to select the configuration class.</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="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>
|
/// <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="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>
|
/// <returns>True when the configuration was successfully processed, otherwise false.</returns>
|
||||||
public static bool TryProcessConfiguration<TClass, TDataType>(
|
public static bool TryProcessConfiguration<TClass, TDataType>(
|
||||||
Expression<Func<Data, TClass>> configSelection,
|
Expression<Func<Data, TClass>> configSelection,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user