internal override void DumpStructure(ExpressionDumper dumper) { if (Query != null) { dumper.Dump(Query, "Query"); } }
internal override void DumpStructure(ExpressionDumper dumper) { if (Target != null) { dumper.Dump(Target, "Target"); } }
internal void Dump(ExpressionDumper dumper) { dumper.Begin(this.GetType().Name, new Dictionary <string, object>() { { "DataSpace", (object)this.DataSpace } }); dumper.Begin("Parameters", (Dictionary <string, object>)null); foreach (KeyValuePair <string, TypeUsage> parameter in this.Parameters) { dumper.Begin("Parameter", new Dictionary <string, object>() { { "Name", (object)parameter.Key } }); dumper.Dump(parameter.Value, "ParameterType"); dumper.End("Parameter"); } dumper.End("Parameters"); this.DumpStructure(dumper); dumper.End(this.GetType().Name); }
internal override void DumpStructure(ExpressionDumper dumper) { if (EdmFunction != null) { dumper.Dump(EdmFunction); } }
/// <summary>Assert.IsTrue(predicate(value))</summary> public static void Is <T>(this T value, Expression <Func <T, bool> > predicate, string message = "") { var condition = predicate.Compile().Invoke(value); var paramName = predicate.Parameters.First().Name; string msg = ""; try { var dumper = new ExpressionDumper <T>(value, predicate.Parameters.Single()); dumper.Visit(predicate); var dump = string.Join(", ", dumper.Members.Select(kvp => kvp.Key + " = " + kvp.Value)); msg = string.Format("\r\n{0} = {1}\r\n{2}\r\n{3}{4}", paramName, value, dump, predicate, string.IsNullOrEmpty(message) ? "" : ", " + message); } catch { msg = string.Format("{0} = {1}, {2}{3}", paramName, value, predicate, string.IsNullOrEmpty(message) ? "" : ", " + message); } Assert.IsTrue(condition, msg); }
internal override void DumpStructure(ExpressionDumper dumper) { if (this.EdmFunction == null) { return; } dumper.Dump(this.EdmFunction); }
internal override void DumpStructure(ExpressionDumper dumper) { if (this.Target == null) { return; } dumper.Dump(this.Target, "Target"); }
internal override void DumpStructure(ExpressionDumper dumper) { if (this.Query == null) { return; } dumper.Dump(this.Query, "Query"); }
internal override void DumpStructure(ExpressionDumper dumper) { base.DumpStructure(dumper); if (this.Predicate == null) { return; } dumper.Dump(this.Predicate, "Predicate"); }
internal override void DumpStructure(ExpressionDumper dumper) { base.DumpStructure(dumper); if (Predicate != null) { dumper.Dump(Predicate, "Predicate"); } }
internal override void DumpStructure(ExpressionDumper dumper) { dumper.Begin("DbSetClause"); if (null != this.Property) { dumper.Dump(this.Property, "Property"); } if (null != this.Value) { dumper.Dump(this.Value, "Value"); } dumper.End("DbSetClause"); }
internal override void DumpStructure(ExpressionDumper dumper) { dumper.Begin(nameof(DbSetClause)); if (this.Property != null) { dumper.Dump(this.Property, "Property"); } if (this.Value != null) { dumper.Dump(this.Value, "Value"); } dumper.End(nameof(DbSetClause)); }
internal override void DumpStructure(ExpressionDumper dumper) { base.DumpStructure(dumper); dumper.Begin("SetClauses"); foreach (DbModificationClause setClause in (IEnumerable <DbModificationClause>) this.SetClauses) { setClause?.DumpStructure(dumper); } dumper.End("SetClauses"); if (this.Returning == null) { return; } dumper.Dump(this.Returning, "Returning"); }
internal override void DumpStructure(ExpressionDumper dumper) { base.DumpStructure(dumper); if (this.Predicate != null) { dumper.Dump(this.Predicate, "Predicate"); } dumper.Begin("SetClauses", (Dictionary <string, object>)null); foreach (DbModificationClause setClause in (IEnumerable <DbModificationClause>) this.SetClauses) { setClause?.DumpStructure(dumper); } dumper.End("SetClauses"); dumper.Dump(this.Returning, "Returning"); }
internal override void DumpStructure(ExpressionDumper dumper) { base.DumpStructure(dumper); dumper.Begin("SetClauses"); foreach (var clause in SetClauses) { if (null != clause) { clause.DumpStructure(dumper); } } dumper.End("SetClauses"); if (null != Returning) { dumper.Dump(Returning, "Returning"); } }
internal override void DumpStructure(ExpressionDumper dumper) { base.DumpStructure(dumper); dumper.Begin("SetClauses"); foreach (DbModificationClause clause in this.SetClauses) { if (null != clause) { clause.DumpStructure(dumper); } } dumper.End("SetClauses"); if (null != this.Returning) { dumper.Dump(this.Returning, "Returning"); } }
static void Main(string[] args) { Func <double, double> lambda = e => e * 2 + 1; Console.WriteLine(lambda(42.0)); Expression <Func <double, double> > expression = e => e * 2 + 1; // When we write this, we don't execute. Instead, we parse the expression Console.WriteLine(expression.ToString( )); // Using the ExpressionDumper class, we can also look at the structure of // the expression tree ExpressionDumper.Output(expression); Expression <Func <Person, bool> > isCalledBoris = p => p.Name == "Boris"; ExpressionDumper.Output(isCalledBoris); //return; // First define the parameter to the expression ParameterExpression parameterExpression = Expression.Parameter(typeof(double), "x"); // Now let's perform the operations on the parameter Expression body = Expression.Add(Expression.Multiply( parameterExpression, Expression.Constant(2.0)), Expression.Constant(1.0)); // Our lambda expression has a body and one or more parameters Expression <Func <double, double> > lambdaExpression = Expression.Lambda <Func <double, double> >(body, parameterExpression); Console.WriteLine(lambdaExpression.ToString()); // We can compile an expression into a delegate Func <double, double> function = lambdaExpression.Compile( ); // Which we then call Console.WriteLine(function(10)); }
internal void Dump(ExpressionDumper dumper) { // // Dump information about this command tree to the specified ExpressionDumper // // First dump standard information - the DataSpace of the command tree and its parameters // Dictionary <string, object> attrs = new Dictionary <string, object>(); attrs.Add("DataSpace", this.DataSpace); dumper.Begin(this.GetType().Name, attrs); // // The name and type of each Parameter in turn is added to the output // dumper.Begin("Parameters", null); foreach (KeyValuePair <string, TypeUsage> param in this.Parameters) { Dictionary <string, object> paramAttrs = new Dictionary <string, object>(); paramAttrs.Add("Name", param.Key); dumper.Begin("Parameter", paramAttrs); dumper.Dump(param.Value, "ParameterType"); dumper.End("Parameter"); } dumper.End("Parameters"); // // Delegate to the derived type's implementation that dumps the structure of the command tree // this.DumpStructure(dumper); // // Matching call to End to correspond with the call to Begin above // dumper.End(this.GetType().Name); }
// Effects: describes the contents of this clause using the given dumper internal abstract void DumpStructure(ExpressionDumper dumper);
internal override void DumpStructure(ExpressionDumper dumper) { throw new NotImplementedException(); }