mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-04-09 18:01:37 +00:00
Some checks are pending
Build and Release / Determine run mode (push) Waiting to run
Build and Release / Read metadata (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage,deb,updater, appimage,deb) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage,deb,updater, appimage,deb) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions
66 lines
3.6 KiB
C#
66 lines
3.6 KiB
C#
using AIStudio.Tools.PluginSystem.Assistants.Icons;
|
|
|
|
namespace AIStudio.Tools.PluginSystem.Assistants.DataModel;
|
|
|
|
internal static class AssistantComponentPropHelper
|
|
{
|
|
public static string ReadString(Dictionary<string, object> props, string key)
|
|
{
|
|
if (props.TryGetValue(key, out var value))
|
|
return value.ToString() ?? string.Empty;
|
|
|
|
return string.Empty;
|
|
}
|
|
|
|
public static void WriteString(Dictionary<string, object> props, string key, string value) => props[key] = value;
|
|
|
|
public static int ReadInt(Dictionary<string, object> props, string key, int fallback = 0)
|
|
{
|
|
return props.TryGetValue(key, out var value) && int.TryParse(value.ToString(), out var i) ? i : fallback;
|
|
}
|
|
|
|
public static void WriteInt(Dictionary<string, object> props, string key, int value) => props[key] = value;
|
|
|
|
public static int? ReadNullableInt(Dictionary<string, object> props, string key)
|
|
{
|
|
return props.TryGetValue(key, out var value) && int.TryParse(value.ToString(), out var i) ? i : null;
|
|
}
|
|
|
|
public static void WriteNullableInt(Dictionary<string, object> props, string key, int? value)
|
|
{
|
|
if (value.HasValue)
|
|
props[key] = value.Value;
|
|
else
|
|
props.Remove(key);
|
|
}
|
|
|
|
public static bool ReadBool(Dictionary<string, object> props, string key, bool fallback = false)
|
|
{
|
|
return props.TryGetValue(key, out var value) && bool.TryParse(value.ToString(), out var b) ? b : fallback;
|
|
}
|
|
|
|
public static void WriteBool(Dictionary<string, object> props, string key, bool value) => props[key] = value;
|
|
|
|
public static void WriteObject(Dictionary<string, object> props, string key, object? value)
|
|
{
|
|
if (value is null)
|
|
props.Remove(key);
|
|
else
|
|
props[key] = value;
|
|
}
|
|
|
|
public static Color GetColor(string value, Color fallback) => Enum.TryParse<Color>(value, out var color) ? color : fallback;
|
|
public static Variant GetVariant(string value, Variant fallback) => Enum.TryParse<Variant>(value, out var variant) ? variant : fallback;
|
|
public static Adornment GetAdornment(string value, Adornment fallback) => Enum.TryParse<Adornment>(value, out var adornment) ? adornment : fallback;
|
|
public static string GetIconSvg(string value) => MudBlazorIconRegistry.TryGetSvg(value.TrimStart('@'), out var svg) ? svg : string.Empty;
|
|
public static Size GetComponentSize(string value, Size fallback) => Enum.TryParse<Size>(value, out var size) ? size : fallback;
|
|
public static Justify? GetJustify(string value) => Enum.TryParse<Justify>(value, out var justify) ? justify : null;
|
|
public static AlignItems? GetItemsAlignment(string value) => Enum.TryParse<AlignItems>(value, out var alignment) ? alignment : null;
|
|
public static Align GetAlignment(string value, Align fallback = Align.Inherit) => Enum.TryParse<Align>(value, out var alignment) ? alignment : fallback;
|
|
public static Typo GetTypography(string value, Typo fallback = Typo.body1) => Enum.TryParse<Typo>(value, out var typo) ? typo : fallback;
|
|
public static Wrap? GetWrap(string value) => Enum.TryParse<Wrap>(value, out var wrap) ? wrap : null;
|
|
public static StretchItems? GetStretching(string value) => Enum.TryParse<StretchItems>(value, out var stretch) ? stretch : null;
|
|
public static Breakpoint GetBreakpoint(string value, Breakpoint fallback) => Enum.TryParse<Breakpoint>(value, out var breakpoint) ? breakpoint : fallback;
|
|
public static PickerVariant GetPickerVariant(string pickerValue, PickerVariant fallback) => Enum.TryParse<PickerVariant>(pickerValue, out var variant) ? variant : fallback;
|
|
}
|