Initial commit

This commit is contained in:
2025-11-15 20:06:01 -05:00
commit 6d50386eba
24 changed files with 1192 additions and 0 deletions

27
Library/EnumExtensions.cs Normal file
View File

@@ -0,0 +1,27 @@
using System.Reflection;
namespace ChrisKaczor.MinifluxClient;
internal static class EnumExtensions
{
internal static TAttribute? GetAttribute<TAttribute>(this Enum enumValue) where TAttribute : Attribute
{
var type = enumValue.GetType();
var name = Enum.GetName(type, enumValue);
if (name == null)
return null;
var field = type.GetField(name);
var attribute = field?.GetCustomAttribute<TAttribute>();
return attribute;
}
extension<T>(T value) where T : Enum
{
internal string QueryPropertyName => value.GetAttribute<QueryParameterNameAttribute>()?.Name ?? string.Empty;
}
}