/// <summary> /// Create a parameter expression /// </summary> public override Expression ToExpression() { if (this.m_expression != null) { return(this.m_expression); } if (this.Type == null) { throw new InvalidOperationException("Type not set"); } // Is there some parameter in the parent context? XmlExpression xe = this.Parent; while (xe != null && this.m_expression == null) { this.m_expression = (xe as XmlLambdaExpression)?.Parameters.Find(o => o.ParameterName == this.ParameterName)?.ToExpression() as ParameterExpression; xe = xe.Parent; } if (this.m_expression == null) { this.m_expression = Expression.Parameter(this.Type, this.ParameterName); } return(this.m_expression); }
/// <summary> /// Initialize context /// </summary> public virtual void InitializeContext(XmlExpression context) { foreach (var itm in this.Item) { itm.InitializeContext(context); } }
/// <summary> /// Initialize context /// </summary> public override void InitializeContext(XmlExpression context) { base.InitializeContext(context); foreach (var itm in this.Parts) { itm.InitializeContext(this); } }
/// <summary> /// Creates an XmlBinaryExpression from the specified binary expression /// </summary> public XmlBinaryExpression(BinaryExpression expr) { BinaryOperatorType opType = BinaryOperatorType.AndAlso; if (!Enum.TryParse <BinaryOperatorType>(expr.NodeType.ToString(), out opType)) { throw new ArgumentOutOfRangeException(nameof(Expression.NodeType)); } this.Operator = opType; this.Parts = new List <XmlExpression>() { XmlExpression.FromExpression(expr.Left), XmlExpression.FromExpression(expr.Right) }; }
/// <summary> /// Initialize context /// </summary> public override void InitializeContext(XmlExpression context) { base.InitializeContext(context); this.Parameters.InitializeContext(this); }
/// <summary> /// Initialize context /// </summary> public override void InitializeContext(XmlExpression context) { base.InitializeContext(context); //foreach (var itm in this.Parameters) // itm.InitializeContext(this); }
/// <summary> /// Creates a new xml expression list /// </summary> public XmlExpressionList(IEnumerable <Expression> expr) { this.Item = new List <XmlExpression>(expr.Select(o => XmlExpression.FromExpression(o))); }
/// <summary> /// Creates the bound expression /// </summary> public XmlBoundExpression(MethodCallExpression expr) { this.Object = XmlExpression.FromExpression(expr.Object); }
/// <summary> /// Creates the bound expression /// </summary> public XmlBoundExpression(UnaryExpression expr) { this.Object = XmlExpression.FromExpression(expr.Operand); }
/// <summary> /// Creates the bound expression /// </summary> public XmlBoundExpression(MemberExpression expr) { this.Object = XmlExpression.FromExpression(expr.Expression); }
/// <summary> /// Creates type bound expression /// </summary> /// <param name="expr"></param> public XmlBoundExpression(TypeBinaryExpression expr) { this.Object = XmlExpression.FromExpression(expr.Expression); }
/// <summary> /// Creates the bound expression /// </summary> public XmlBoundExpression(Expression expr) { this.Object = XmlExpression.FromExpression(expr); }
/// <summary> /// Initialize context /// </summary> public override void InitializeContext(XmlExpression context) { base.InitializeContext(context); this.Object?.InitializeContext(this); }
/// <summary> /// Initialize the context /// </summary> public virtual void InitializeContext(XmlExpression context) { this.Parent = context; }