mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 11:26:27 +00:00
UI - Settings General tab
This commit is contained in:
1 parent
491a0bdbc3
commit
6bbe6b6bbe
27 files changed
+831
-21
No files matched your search
@@ -33,7 +33,6 @@ namespace Artemis.Core
|
||||
/// <typeparam name="T">The type of the setting, can be any serializable type</typeparam>
|
||||
/// <param name="name">The name of the setting</param>
|
||||
/// <param name="defaultValue">The default value to use if the setting does not exist yet</param>
|
||||
/// <returns></returns>
|
||||
public PluginSetting<T> GetSetting<T>(string name, T? defaultValue = default)
|
||||
{
|
||||
lock (_settingEntities)
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Humanizer;
|
||||
|
||||
namespace Artemis.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides utilities for display enums in a human readable form
|
||||
/// </summary>
|
||||
public static class EnumUtilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a list containing a tuple for each value in the enum type
|
||||
/// </summary>
|
||||
/// <param name="t">The enum type to create value descriptions for</param>
|
||||
/// <returns>A list containing a value-description tuple for each value in the enum type</returns>
|
||||
public static List<(T, string)> GetAllValuesAndDescriptions<T>() where T : struct, Enum
|
||||
{
|
||||
return Enum.GetValues<T>().Select(e => (e, e.Humanize())).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list containing a tuple for each value in the enum type
|
||||
/// </summary>
|
||||
/// <param name="t">The enum type to create value descriptions for</param>
|
||||
/// <returns>A list containing a value-description tuple for each value in the enum type</returns>
|
||||
public static List<(Enum, string)> GetAllValuesAndDescriptions(Type t)
|
||||
{
|
||||
if (!t.IsEnum)
|
||||
throw new ArgumentException($"{t} must be an enum type");
|
||||
|
||||
return Enum.GetValues(t).Cast<Enum>().Select(e => (e, e.Humanize())).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user