narsil/Tanshu.Accounts.Repository/Fluent/AllowNullConvention.cs
2011-03-12 17:12:02 +05:30

34 lines
1.1 KiB
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 AllowNullConvention : IPropertyConvention, IPropertyConventionAcceptance
// {
// public void Accept(IAcceptanceCriteria<IPropertyInspector> criteria)
// {
// criteria.Expect(
// x => !this.IsNullableProperty(x)
// || x.Property.MemberInfo.GetCustomAttributes(typeof(AllowNullAttribute), true).Length > 0);
// }
// public void Apply(IPropertyInstance instance)
// {
// instance.Nullable();
// }
// private bool IsNullableProperty(IExposedThroughPropertyInspector target)
// {
// var type = target.Property.PropertyType;
// return type.Equals(typeof(string)) || (type.IsGenericType && type.GetGenericTypeDefinition().Equals(typeof(Nullable<>)));
// }
// }
//}