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
{
///
/// Helper class to assign descriptions to enum values
///
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
}
}
///
/// Identifies the type of data storage
///
public enum DataStorageType
{
RestApi,
Database,
Json,
Csv
}
}