Exemplo n.º 1
0
        public Transformer(Func <Type, MemberInfo, int> membersOrder1 = null, Func <Type, MemberInfo, int> membersOrder2 = null)
        {
            if (!TransformerHelper.CheckCompatible(typeof(T1), typeof(T2), new HashSet <Type>(), membersOrder1, membersOrder2))
            {
                throw new ArgumentException(String.Format("{0} not compatible with {1}", typeof(T1).ToString(), typeof(T2).ToString()));
            }

            Type1         = typeof(T1);
            Type2         = typeof(T2);
            MembersOrder1 = membersOrder1;
            MembersOrder2 = membersOrder2;

            to   = CreateToMethod().Compile();
            from = CreateFromMethod().Compile();
        }
Exemplo n.º 2
0
        public DataTransformer(Type type2, Func <Type, MemberInfo, int> membersOrder1 = null, Func <Type, MemberInfo, int> membersOrder2 = null)
        {
            if (!TransformerHelper.CheckCompatible(typeof(T), type2, new HashSet <Type>(), membersOrder1, membersOrder2))
            {
                throw new ArgumentException(String.Format("Type {0} is not compatible with {1}", typeof(T), type2));
            }

            Type1 = typeof(T);
            Type2 = type2;

            MembersOrder1 = membersOrder1;
            MembersOrder2 = membersOrder2;

            LambdaTo = CreateToMethod();
            to       = LambdaTo.Compile();

            LambdaFrom = CreateFromMethod();
            from       = LambdaFrom.Compile();
        }