public ExprDeclaredNodeImpl( ExpressionDeclItem prototype, IList<ExprNode> chainParameters, ContextCompileTimeDescriptor contextDescriptor, ExprNode expressionBodyCopy) { PrototypeWVisibility = prototype; ChainParameters = chainParameters; ExpressionBodyCopy = expressionBodyCopy; // replace context-properties where they are currently identifiers if (contextDescriptor == null) { return; } var visitorWParent = new ExprNodeIdentVisitorWParent(); expressionBodyCopy.Accept(visitorWParent); foreach (var pair in visitorWParent.IdentNodes) { var streamOrProp = pair.Second.StreamOrPropertyName; if (streamOrProp != null && contextDescriptor.ContextPropertyRegistry.IsContextPropertyPrefix(streamOrProp)) { var context = new ExprContextPropertyNodeImpl(pair.Second.UnresolvedPropertyName); if (pair.First == null) { ExpressionBodyCopy = context; } else { ExprNodeUtilityModify.ReplaceChildNode(pair.First, pair.Second, context); } } } }
public ExprDeclaredNodeImpl( IContainer container, ExpressionDeclItem prototype, IList <ExprNode> chainParameters, ContextDescriptor contextDescriptor) { _prototype = prototype; _chainParameters = chainParameters; // copy expression - we do it at this time and not later try { _expressionBodyCopy = (ExprNode)SerializableObjectCopier.Copy(container, prototype.Inner); } catch (Exception e) { throw new Exception("Internal error providing expression tree: " + e.Message, e); } // replace context-properties where they are currently identifiers if (contextDescriptor == null) { return; } var visitorWParent = new ExprNodeIdentVisitorWParent(); _expressionBodyCopy.Accept(visitorWParent); foreach (var pair in visitorWParent.IdentNodes) { var streamOrProp = pair.Second.StreamOrPropertyName; if (streamOrProp != null && contextDescriptor.ContextPropertyRegistry.IsContextPropertyPrefix(streamOrProp)) { var context = new ExprContextPropertyNode(pair.Second.UnresolvedPropertyName); if (pair.First == null) { _expressionBodyCopy = context; } else { ExprNodeUtility.ReplaceChildNode(pair.First, pair.Second, context); } } } }