59909a5ee7
Must use the Repositories with Using or else bad things will happen.
27 lines
986 B
C#
27 lines
986 B
C#
using System;
|
|
using FluentNHibernate.Conventions;
|
|
using FluentNHibernate.Conventions.Instances;
|
|
using FluentNHibernate.Conventions.Inspections;
|
|
using FluentNHibernate.Conventions.AcceptanceCriteria;
|
|
using System.Diagnostics;
|
|
|
|
namespace Tanshu.Accounts.Conventions
|
|
{
|
|
public class EnumConvention : IUserTypeConvention
|
|
{
|
|
public void Accept(IAcceptanceCriteria<IPropertyInspector> criteria)
|
|
{
|
|
criteria.Expect(x => (x.Property.PropertyType.IsEnum
|
|
|| (x.Property.PropertyType.IsGenericType &&
|
|
x.Property.PropertyType.GetGenericTypeDefinition() == typeof(Nullable<>) &&
|
|
x.Property.PropertyType.GetGenericArguments()[0].IsEnum)));
|
|
}
|
|
|
|
public void Apply(IPropertyInstance target)
|
|
{
|
|
Trace.TraceInformation(string.Format("Custom Enum for {0}.{1}", target.EntityType.Name, target.Property.Name));
|
|
target.CustomType(target.Property.PropertyType);
|
|
}
|
|
}
|
|
}
|