52 lines
1.3 KiB
C#
52 lines
1.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace TBF.Rig.Input.DataStorage.UniDataStorageReader
|
|
{
|
|
/// <summary>
|
|
/// Helper class to assign descriptions to enum values
|
|
/// </summary>
|
|
public class Description : Attribute
|
|
{
|
|
public string Text;
|
|
public Description(string t)
|
|
{
|
|
Text = t;
|
|
}
|
|
}
|
|
|
|
public static class GetDescription
|
|
{
|
|
/// Extension method for enum-s
|
|
public static string ToDescription(this Enum en)
|
|
{
|
|
Type type = en.GetType();
|
|
MemberInfo[] memInfo = type.GetMember(en.ToString());
|
|
|
|
if (memInfo != null && memInfo.Length > 0)
|
|
{
|
|
object[] attrs = memInfo[0].GetCustomAttributes(typeof(Description), false);
|
|
if (attrs != null && attrs.Length > 0)
|
|
return ((Description)attrs[0]).Text;
|
|
}
|
|
|
|
return en.ToString(); /// Return ToString() value in case there is no description
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Identifies the type of data storage
|
|
/// </summary>
|
|
public enum DataStorageType
|
|
{
|
|
RestApi,
|
|
Database,
|
|
Json,
|
|
Csv
|
|
}
|
|
}
|