示例#1
0
        private Expression <Action <BinaryWriter, Func <int, IData>, int> > CreateStoreMethod()
        {
            var writer = Expression.Parameter(typeof(BinaryWriter), "writer");
            var values = Expression.Parameter(typeof(Func <int, IData>), "values");
            var count  = Expression.Parameter(typeof(int), "count");

            var idx        = Expression.Variable(typeof(int), "idx");
            var callValues = Expression.Convert(Expression.Call(values, values.Type.GetMethod("Invoke"), idx), typeof(Data <>).MakeGenericType(Type)).Value();

            var body   = IndexerPersistHelper.CreateStoreBody(Type, Persists, writer, callValues, idx, count, MembersOrder);
            var lambda = Expression.Lambda <Action <BinaryWriter, Func <int, IData>, int> >(body, new ParameterExpression[] { writer, values, count });

            return(lambda);
        }
示例#2
0
        public Expression <Action <BinaryWriter, Func <int, T>, int> > CreateStoreMethod()
        {
            var writer = Expression.Parameter(typeof(BinaryWriter), "writer");
            var values = Expression.Parameter(typeof(Func <int, T>), "func");
            var count  = Expression.Parameter(typeof(int), "count");

            var idx        = Expression.Variable(typeof(int), "idx");
            var callValues = Expression.Call(values, values.Type.GetMethod("Invoke"), idx);

            var body = IndexerPersistHelper.CreateStoreBody(Type, Persists, writer, callValues, idx, count, MembersOrder);

            var lambda = Expression.Lambda <Action <BinaryWriter, Func <int, T>, int> >(body, new ParameterExpression[] { writer, values, count });

            return(lambda);
        }