narsil/Tanshu.Accounts.Repository/Fluent/UniqueConvention.cs

24 lines
817 B
C#
Raw Normal View History

using FluentNHibernate.Conventions;
using FluentNHibernate.Conventions.Instances;
using FluentNHibernate.Conventions.Inspections;
using FluentNHibernate.Conventions.AcceptanceCriteria;
using Tanshu.Accounts.SqlDAO;
using System.Diagnostics;
namespace Tanshu.Accounts.Conventions
{
public class UniqueConvention : IPropertyConvention, IPropertyConventionAcceptance
{
public void Apply(IPropertyInstance instance)
{
var property = instance.Property;
Trace.TraceInformation("Unique on {0}.{1}", property.DeclaringType.Name, property.Name);
instance.Unique();
}
public void Accept(IAcceptanceCriteria<IPropertyInspector> criteria)
{
criteria.Expect(x => AttributeChecker.Unique(x.Property.MemberInfo));
}
}
}