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);
        }
Exemplo n.º 4
0
        public void Apply(ITypeConventionContext context)
        {
            // Register every public property on this type
            foreach (var property in context.Target
                     .GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance)
                     .Where(x => !x.PropertyType.ContainsGenericParameters && IsDefinedOnType(x, context.Target)))
            {
                if (PropertyHasPublicSetter(property))
                {
                    context.RegisterProperty(property);
                }
            }

            // Register every public field on this type
            foreach (var field in context.Target
                     .GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance)
                     .Where(x => !x.FieldType.ContainsGenericParameters && IsDefinedOnType(x, context.Target)))
            {
                context.RegisterField(field);
            }
        }
        public void Apply(ITypeConventionContext context)
        {
            // Register every public property on this type
            foreach(var property in context.Target
                .GetProperties( System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance)
                .Where(x => !x.PropertyType.ContainsGenericParameters && IsDefinedOnType(x, context.Target)))
            {
                if(PropertyHasPublicSetter(property))
                {
                    context.RegisterProperty(property);
                }
            }

            // Register every public field on this type
            foreach (var field in context.Target
                .GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance)
                .Where(x => !x.FieldType.ContainsGenericParameters && IsDefinedOnType(x, context.Target)))
            {
                context.RegisterField(field);
            }
        }
        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)
 {
     context.RegisterProperty(typeof(TestType).GetProperty("TestProperty"));
     context.RegisterField(typeof(TestType).GetField("TestField"));
 }
 public void Apply(ITypeConventionContext context)
 {
     context.RegisterProperty(typeof(TestType).GetProperty("TestProperty"));
     context.RegisterField(typeof(TestType).GetField("TestField"));
 }
 public void Apply(ITypeConventionContext context)
 {
     context.RegisterField(typeof(TestTypeClass).GetField("Test"));
 }
 public void Apply(ITypeConventionContext context)
 {
     context.RegisterField(typeof(TestTypeClass).GetField("Test"));
 }