public Expression <Func <IData, string> > CreateToMethod() { var data = Expression.Parameter(typeof(IData), "data"); var d = Expression.Variable(typeof(Data <>).MakeGenericType(Type), "d"); List <Expression> list = new List <Expression>(); list.Add(Expression.Assign(d, Expression.Convert(data, typeof(Data <>).MakeGenericType(Type)))); list.Add(ValueToStringHelper.CreateToStringBody(d.Value(), StringBuilderCapacity, Providers, Delimiters[0], MembersOrder)); var body = Expression.Block(new ParameterExpression[] { d }, list); return(Expression.Lambda <Func <IData, string> >(body, data)); }
public Expression <Func <T, string> > CreateToMethod() { var item = Expression.Parameter(typeof(T)); return(Expression.Lambda <Func <T, string> >(ValueToStringHelper.CreateToStringBody(item, StringBuilderCapacity, Providers, Delimiters[0], MembersOrder), new ParameterExpression[] { item })); }