using System;
using System.Reflection;
namespace JWH.DATA
{
public static class CustomerAttributes
{
///
/// Primary Key Attribute
///
public sealed class PrimaryKeyAttribute : Attribute
{
public bool PrimaryKey { get; }
public PrimaryKeyAttribute(bool value)
{
this.PrimaryKey = value;
}
}
///
/// Length Attribute
///
public sealed class LengthAttribute : Attribute
{
public int Length { get; }
public LengthAttribute(int length)
{
this.Length = length;
}
}
///
/// PropertyInfo.LengthAttribute 속성값을 반환한다
///
///
///
public static int GetPropertyLength(this PropertyInfo property)
{
try
{
LengthAttribute attribute = (LengthAttribute)Attribute.GetCustomAttribute(property, typeof(LengthAttribute), true);
if (attribute == null) return 0;
return attribute.Length;
}
catch (Exception ex)
{
XLogger.Instance.Fatal(ex);
throw ex;
}
}
}
}