Files
DP44/Common/DTS.Common.Storage/Classes/Static/CustomChannelFieldSizeAttribute.cs
2026-04-17 14:55:32 -04:00

35 lines
1011 B
C#

using System;
using System.Linq;
namespace DTS.Storage
{
#region CustomChannelFieldSizeExtensions
public class CustomChannelFieldSizeAttribute : Attribute
{
internal CustomChannelFieldSizeAttribute(int size)
{
this.Size = size;
}
public int Size { get; private set; }
}
public static class CustomChannelFieldSizeExtensions
{
public static int GetFieldSize(MMETables.MMEPossibleChannelsFields field)
{
return (field.GetAttribute<CustomChannelFieldSizeAttribute>()).Size;
}
}
public static class EnumExtensions
{
public static TAttribute GetAttribute<TAttribute>(this Enum value)
where TAttribute : Attribute
{
return (value.GetType()).GetField(Enum.GetName(value.GetType(), value)).GetCustomAttributes(false).OfType<TAttribute>().SingleOrDefault();
}
}
#endregion CustomChannelFieldSizeExtensions
}