narsil/Tanshu.Accounts.Repository/Fluent/AttributeChecker.cs
unknown 59909a5ee7 Updated NH, Code Refactoring, made all DB transactions atomic.
Must use the Repositories with Using or else bad things will happen.
2011-06-30 01:57:07 +05:30

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;
}
}
}