59909a5ee7
Must use the Repositories with Using or else bad things will happen.
35 lines
1.3 KiB
C#
35 lines
1.3 KiB
C#
using System.Reflection;
|
|
using Tanshu.Accounts.Contracts;
|
|
|
|
namespace Tanshu.Accounts.SqlDAO
|
|
{
|
|
public static class AttributeChecker
|
|
{
|
|
public static bool Cascade(ICustomAttributeProvider provider)
|
|
{
|
|
return provider.GetCustomAttributes(typeof(CascadeAttribute), false).Length == 1;
|
|
}
|
|
public static bool Inverse(ICustomAttributeProvider provider)
|
|
{
|
|
return provider.GetCustomAttributes(typeof(InverseAttribute), false).Length == 1;
|
|
}
|
|
public static bool Unique(ICustomAttributeProvider provider)
|
|
{
|
|
return provider.GetCustomAttributes(typeof(UniqueAttribute), false).Length == 1;
|
|
}
|
|
public static bool NotNull(ICustomAttributeProvider provider)
|
|
{
|
|
return provider.GetCustomAttributes(typeof(NotNullAttribute), false).Length == 1;
|
|
}
|
|
public static bool Formula(ICustomAttributeProvider provider)
|
|
{
|
|
return provider.GetCustomAttributes(typeof(FormulaAttribute), false).Length == 1;
|
|
}
|
|
public static string GetFormula(ICustomAttributeProvider provider)
|
|
{
|
|
var vv = (FormulaAttribute)provider.GetCustomAttributes(typeof(FormulaAttribute), false)[0];
|
|
return vv.Formula;
|
|
}
|
|
}
|
|
}
|