public override void Explain(NewArrayExpression exp, Content info) { info.IsNewArray(); foreach (var item in exp.Expressions) // 循环解析表达式 { ExplainTool.Explain(item, info); } info.OverNewArray(); // 数组结束 }
public override void Explain(MethodCallExpression exp, Content info) { if (ExplainTool.Methods.Contains(exp.Method.Name)) { if (ExplainTool.MethodLikes.Contains(exp.Method.Name)) { ExplainTool.Explain(exp.Object, info); } ExplainTool.Explain(exp.Arguments[0], info); info.Append(exp.Method); if (exp.Arguments.Count > 1) { ExplainTool.Explain(exp.Arguments[1], info); } } else { info.Append(Expression.Lambda(exp).Compile().DynamicInvoke()); } }
public override void Explain(MemberExpression exp, Content info) { if (exp.Expression != null) { if (exp.Expression is ConstantExpression constant) { // 如果是变量直接取值 info.Append(constant.Value.GetType().InvokeMember(exp.Member.Name, BindingFlags.GetField, null, constant.Value, null)); } else { ExplainTool.Explain(exp.Expression, info); info.Append(exp.Member.Name); // 如果树的右边也是个表达式 比如 Join 方法 } } else { // 目前只有datetime.now之类的右边值会走到这,考虑标记为唯一差异化对待datetime ExplainTool.Explain(exp.Expression, info); info.Append(exp.Member); } }
public override void Explain(BinaryExpression exp, Content info) { ExplainTool.Explain(exp.Left, info); info.Append(exp.NodeType); // 比较符 ExplainTool.Explain(exp.Right, info); // 树的右边有多种情况 }
public override void Explain(LambdaExpression exp, Content info) { ExplainTool.Explain(exp.Body, info); }
public override void Explain(ListInitExpression exp, Content info) { ExplainTool.Explain(exp.NewExpression, info); }
public override void Explain(UnaryExpression exp, Content info) { ExplainTool.Explain(exp.Operand, info); }