64 lines
1.4 KiB
C#
64 lines
1.4 KiB
C#
using System;
|
|
using System.Reflection;
|
|
|
|
namespace JWH.DATA
|
|
{
|
|
|
|
public static class CustomerAttributes
|
|
{
|
|
|
|
/// <summary>
|
|
/// Primary Key Attribute
|
|
/// </summary>
|
|
public sealed class PrimaryKeyAttribute : Attribute
|
|
{
|
|
|
|
public bool PrimaryKey { get; }
|
|
|
|
public PrimaryKeyAttribute(bool value)
|
|
{
|
|
this.PrimaryKey = value;
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Length Attribute
|
|
/// </summary>
|
|
public sealed class LengthAttribute : Attribute
|
|
{
|
|
|
|
public int Length { get; }
|
|
|
|
public LengthAttribute(int length)
|
|
{
|
|
this.Length = length;
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// PropertyInfo.LengthAttribute 속성값을 반환한다
|
|
/// </summary>
|
|
/// <param name="property"></param>
|
|
/// <returns></returns>
|
|
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;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|