public class EnumToInt : ConventionInjection
        {
            protected override bool Match(ConventionInfo c)
            {
                return c.SourceProp.Name == c.TargetProp.Name &&
                    c.SourceProp.Type.IsSubclassOf(typeof (Enum)) && c.TargetProp.Type == typeof (int);
            }
        }      
     
        public class IntToEnum : ConventionInjection
        {
            protected override bool Match(ConventionInfo c)
            {
                return c.SourceProp.Name == c.TargetProp.Name &&
                    c.SourceProp.Type == typeof (int) && c.TargetProp.Type.IsSubclassOf(typeof (Enum));
            }
        }

        //e.g. int? -> int
        public class NullablesToNormal : ConventionInjection
        {
            protected override bool Match(ConventionInfo c)
            {
                return c.SourceProp.Name == c.TargetProp.Name &&
                       Nullable.GetUnderlyingType(c.SourceProp.Type) == c.TargetProp.Type;
            }
        }
        //e.g. int -> int?
        public class NormalToNullables: ConventionInjection
        {
            protected override bool Match(ConventionInfo c)
            {
                return c.SourceProp.Name == c.TargetProp.Name &&
                       c.SourceProp.Type == Nullable.GetUnderlyingType(c.TargetProp.Type);
            }
        } 

Last edited Mar 2, 2011 at 1:13 PM by o, version 2

Comments

No comments yet.