Implemented Core client

This commit is contained in:
2024-10-23 21:00:23 +02:00
parent 3c8d5137ff
commit 83620cb450
43 changed files with 4218 additions and 2 deletions

View File

@@ -0,0 +1,33 @@
using System;
using System.Linq;
using System.Runtime.Serialization;
namespace AMWD.Net.Api.Cloudflare
{
/// <summary>
/// Extension methods for <see cref="Enum"/>s.
/// </summary>
public static class EnumExtensions
{
/// <summary>
/// Gets the <see cref="EnumMemberAttribute.Value"/> of the <see cref="Enum"/> when available, otherwise the <see cref="Enum.ToString()"/>.
/// </summary>
/// <param name="value">The enum value.</param>
public static string GetEnumMemberValue(this Enum value)
{
var fieldInfo = value.GetType().GetField(value.ToString());
if (fieldInfo == null)
return value.ToString();
var enumMember = fieldInfo
.GetCustomAttributes(typeof(EnumMemberAttribute), inherit: false)
.Cast<EnumMemberAttribute>()
.FirstOrDefault();
if (enumMember == null)
return value.ToString();
return enumMember.Value;
}
}
}