Beispiel #1
0
        public Expression <Func <T, int> > CreateGetHashCode()
        {
            var obj = Expression.Parameter(Type);

            var body   = EqualityComparerHelper.CreateGetHashCodeBody(obj, MembersOrder);
            var lambda = Expression.Lambda <Func <T, int> >(body, obj);

            return(lambda);
        }
        public Expression <Func <IData, int> > CreateGetHashCodeMethod()
        {
            var obj      = Expression.Parameter(typeof(IData));
            var objValue = Expression.Variable(Type);

            var dataType = typeof(Data <>).MakeGenericType(Type);

            var body = Expression.Block(typeof(int), new ParameterExpression[] { objValue },
                                        Expression.Assign(objValue, Expression.Convert(obj, dataType).Value()),
                                        EqualityComparerHelper.CreateGetHashCodeBody(objValue, MembersOrder)
                                        );
            var lambda = Expression.Lambda <Func <IData, int> >(body, obj);

            return(lambda);
        }