You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
786 B
27 lines
786 B
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<T>(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;
|
|
}
|
|
}
|
|
} |