25 lines
751 B
C#
25 lines
751 B
C#
|
using System;
|
|||
|
using FluentNHibernate.Conventions;
|
|||
|
using System.Reflection;
|
|||
|
using FluentNHibernate;
|
|||
|
using FluentNHibernate.Conventions.Instances;
|
|||
|
using FluentNHibernate.Conventions.Inspections;
|
|||
|
using FluentNHibernate.Conventions.AcceptanceCriteria;
|
|||
|
using Tanshu.Accounts.Contracts;
|
|||
|
|
|||
|
namespace Tanshu.Accounts.Conventions
|
|||
|
{
|
|||
|
public class NotNullConvention : IPropertyConvention
|
|||
|
{
|
|||
|
public void Apply(IPropertyInstance instance)
|
|||
|
{
|
|||
|
if (!HasAttribute(instance.Property.MemberInfo)) return;
|
|||
|
instance.Not.Nullable();
|
|||
|
}
|
|||
|
bool HasAttribute(ICustomAttributeProvider provider)
|
|||
|
{
|
|||
|
return provider.GetCustomAttributes(typeof(NotNullAttribute), false).Length == 1;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|