transport loading order status in brisanje

This commit is contained in:
David Štaleker
2023-06-26 08:12:25 +02:00
parent 25e98d63ec
commit 625b013b67
13 changed files with 2405 additions and 26 deletions

View File

@@ -0,0 +1,41 @@
using System.Reflection;
using System;
using System.Collections.Generic;
using System.Linq;
namespace EveryThing.Classes
{
public static class Global
{
public static T GetAttributeOfType<T>(this Enum iEnumType) where T : System.Attribute
{
var type = iEnumType.GetType();
var memberInfo = type.GetMember(iEnumType.ToString());
var atributi = memberInfo[0].GetCustomAttributes(typeof(T), false);
return (atributi.Length > 0) ? (T)atributi[0] : null;
}
public static List<(int EnumValue, T EnumAttribute)> GetEnumListClass<T>(this Type iEnumType,
bool iUseOrder = false) where T : System.Attribute
{
List<(int EnumValue, T EnumAttribute)> titleValue = new();
foreach (var tempEnumValue in Enum.GetValues(iEnumType).Cast<Enum>())
{
object tempObject = GetAttributeOfType<T>(tempEnumValue);
titleValue.Add((Convert.ToInt32(tempEnumValue), (T)tempObject));
}
return titleValue.ToList();
}
public static TAttribute GetAttribute<TAttribute>(Enum value)
where TAttribute : Attribute
{
var enumType = value.GetType();
var name = Enum.GetName(enumType, value);
return enumType.GetField(name)?.GetCustomAttributes(false).OfType<TAttribute>().SingleOrDefault();
}
}
}