public void Apply(ITypeConventionContext context) { Type type = context.Target; if (type.IsPrimitive || type == typeof (Decimal)) { context.SetFactory(typeof (DefaultSource<>).MakeGenericType(type)); } else if (type == typeof (string)) { context.SetFactory(typeof (DefaultStringSource)); } }
public void Apply(ITypeConventionContext context) { var type = context.Target; if (type.IsPrimitive || type == typeof(Decimal)) { context.SetFactory(typeof(DefaultSource <>).MakeGenericType(type)); } else if (type == typeof(string)) { context.SetFactory(typeof(DefaultStringSource)); } }
public void Apply(ITypeConventionContext context) { var type = context.Target; if (type.IsPrimitive || type == typeof(Decimal) || type == typeof(string)) { return; } var ctor = type.GetConstructors(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly) .OrderBy(x => x.GetParameters().Count()) .FirstOrDefault(); if (ctor == null) { return; } var ctorSourceType = typeof (CtorSource<>).MakeGenericType(type); context.SetFactory(ctorSourceType, ctor); }
public void Apply(ITypeConventionContext context) { var type = context.Target; if (type.IsPrimitive || type == typeof(Decimal) || type == typeof(string)) { return; } var ctor = type.GetConstructors(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly) .OrderBy(x => x.GetParameters().Count()) .FirstOrDefault(); if (ctor == null) { return; } var ctorSourceType = typeof(CtorSource <>).MakeGenericType(type); context.SetFactory(ctorSourceType, ctor); }