I created a ToStringBuilder (found) that shows the types and dynamically It works well, but I've discovered it for errors on I have made the following test case to show failure. Exception is .. resolved it, its use expression s creates fast
toaster ways to compile.
DateTime . This
stringbuilder The append (object) is pressed when trying to call to pass the
date time . Do I need to create an expression for box value types? How is this best done?
// Pass [TEST] Public Zero update time () {stringbilder sb = new stringbilder (); Sb.Append (new date time ()); } // throws [test] Public Zero expression AppendDateTime () {parameter expedition sbArgExpression = Expression.Parameter (typef (stringbilder), "SB"); Parameter expiration datetimeAgxpress = expression.pemeter (typef (datetime), "datetime"); Var Append Mode Method = Typefinder (stringbinder) .GetMethod ("Add", New [] {Typef (DateTime)}); Var call = expression Call (sbArgExpression, Append Mode, Datetime ERGation); // This line throws on var lambda = Expression.Lambda & lt; StringBuilder DATETIME, & gt; & Gt; (Call sbArgExpression, dateTimeArgExpression) .Compile (); Var datetime = new date time (); Var sb = new stringbilder (); Lambda Invoke (sb, date time); }
System.ArgumentException was rejected by user code Message = expression type used for the 'System.DateTime' parameter Can not be used in the type of method 'System.Object' 'System.Text.StringBuilder enclosed (System.Object)' source = System.Core of StackTrace: System.Linq.Expressions.Expression.ValidateOneArgument (MethodBase method, ExpressionType nodeKind, Expression Arg, debate on System.Linq.Expressions.Expression.Call on ParameterInfo System (Expression Example, MethodInfo Method, IEnumerable`1 argument); System.Linq.Expressions.Expression.ValidateArgumentTypes (MethodBase method, ExpressionType nodeKind, pi on ReadOnlyCollection`1 & amp; Linq.Expressions.Expression.Call (Expression Example, MethodInfo Method, Expression [] Logic) Test.TestToStringBuilder.ExpressionAppendDateTime () InnerException with Less:
expression To use type AS , the active value type as non-primary
object
Comments
Post a Comment