using Application.Domain.Entities; using Infrastructure.Extensions; using IoT.Shared.Application.Models; using NJsonSchema; using System; using System.ComponentModel.DataAnnotations; using System.Globalization; using System.Linq; namespace IoT.Shared.Services { public static class DeviceExtensions { public static T GetAttribute(this Enum value) where T : Attribute { if (value is null) { throw new ArgumentNullException(nameof(value)); } var type = value.GetType(); var name = Enum.GetName(type, value); var field = type.GetField(name); var attribute = Attribute.GetCustomAttribute(field, typeof(T)) as T; return attribute; } } }