Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / XmlUtils / System / Xml / Xsl / QIL / QilScopedVisitor.cs / 1 / QilScopedVisitor.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //----------------------------------------------------------------------------- using System; using System.Collections.Generic; namespace System.Xml.Xsl.Qil { ////// Adds iterator and function scoping to the QilVisitor implementation. /// internal class QilScopedVisitor : QilVisitor { //----------------------------------------------- // QilScopedVisitor methods //----------------------------------------------- ////// Called when a variable, parameter, or function enters scope. /// protected virtual void BeginScope(QilNode node) { } ////// Called when a variable, parameter, or function exits scope. /// protected virtual void EndScope(QilNode node) { } ////// Called at the beginning of Visit(). /// protected virtual void BeforeVisit(QilNode node) { QilExpression qil; switch (node.NodeType) { case QilNodeType.QilExpression: // Put all global functions, variables, and parameters in scope qil = (QilExpression) node; foreach (QilNode param in qil.GlobalParameterList) BeginScope(param); foreach (QilNode var in qil.GlobalVariableList) BeginScope(var); foreach (QilNode func in qil.FunctionList) BeginScope(func); break; case QilNodeType.Function: // Put all formal arguments in scope foreach (QilNode arg in ((QilFunction) node).Arguments) BeginScope(arg); break; case QilNodeType.Loop: case QilNodeType.Filter: case QilNodeType.Sort: // Put loop iterator in scope BeginScope(((QilLoop) node).Variable); break; } } ////// Called at the end of Visit(). /// protected virtual void AfterVisit(QilNode node) { QilExpression qil; switch (node.NodeType) { case QilNodeType.QilExpression: // Remove all global functions, variables, and parameters from scope qil = (QilExpression) node; foreach (QilNode func in qil.FunctionList) EndScope(func); foreach (QilNode var in qil.GlobalVariableList) EndScope(var); foreach (QilNode param in qil.GlobalParameterList) EndScope(param); break; case QilNodeType.Function: // Remove all formal arguments from scope foreach (QilNode arg in ((QilFunction) node).Arguments) EndScope(arg); break; case QilNodeType.Loop: case QilNodeType.Filter: case QilNodeType.Sort: // Remove loop iterator in scope EndScope(((QilLoop) node).Variable); break; } } //----------------------------------------------- // QilVisitor overrides //----------------------------------------------- ////// Call BeforeVisit() and AfterVisit(). /// protected override QilNode Visit(QilNode n) { QilNode ret; BeforeVisit(n); ret = base.Visit(n); AfterVisit(n); return ret; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //----------------------------------------------------------------------------- using System; using System.Collections.Generic; namespace System.Xml.Xsl.Qil { ////// Adds iterator and function scoping to the QilVisitor implementation. /// internal class QilScopedVisitor : QilVisitor { //----------------------------------------------- // QilScopedVisitor methods //----------------------------------------------- ////// Called when a variable, parameter, or function enters scope. /// protected virtual void BeginScope(QilNode node) { } ////// Called when a variable, parameter, or function exits scope. /// protected virtual void EndScope(QilNode node) { } ////// Called at the beginning of Visit(). /// protected virtual void BeforeVisit(QilNode node) { QilExpression qil; switch (node.NodeType) { case QilNodeType.QilExpression: // Put all global functions, variables, and parameters in scope qil = (QilExpression) node; foreach (QilNode param in qil.GlobalParameterList) BeginScope(param); foreach (QilNode var in qil.GlobalVariableList) BeginScope(var); foreach (QilNode func in qil.FunctionList) BeginScope(func); break; case QilNodeType.Function: // Put all formal arguments in scope foreach (QilNode arg in ((QilFunction) node).Arguments) BeginScope(arg); break; case QilNodeType.Loop: case QilNodeType.Filter: case QilNodeType.Sort: // Put loop iterator in scope BeginScope(((QilLoop) node).Variable); break; } } ////// Called at the end of Visit(). /// protected virtual void AfterVisit(QilNode node) { QilExpression qil; switch (node.NodeType) { case QilNodeType.QilExpression: // Remove all global functions, variables, and parameters from scope qil = (QilExpression) node; foreach (QilNode func in qil.FunctionList) EndScope(func); foreach (QilNode var in qil.GlobalVariableList) EndScope(var); foreach (QilNode param in qil.GlobalParameterList) EndScope(param); break; case QilNodeType.Function: // Remove all formal arguments from scope foreach (QilNode arg in ((QilFunction) node).Arguments) EndScope(arg); break; case QilNodeType.Loop: case QilNodeType.Filter: case QilNodeType.Sort: // Remove loop iterator in scope EndScope(((QilLoop) node).Variable); break; } } //----------------------------------------------- // QilVisitor overrides //----------------------------------------------- ////// Call BeforeVisit() and AfterVisit(). /// protected override QilNode Visit(QilNode n) { QilNode ret; BeforeVisit(n); ret = base.Visit(n); AfterVisit(n); return ret; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- PeerServiceMessageContracts.cs
- CodeBinaryOperatorExpression.cs
- SrgsNameValueTag.cs
- UrlPath.cs
- EntityContainerEmitter.cs
- PrintingPermissionAttribute.cs
- DBAsyncResult.cs
- ChangePassword.cs
- precedingsibling.cs
- FactoryRecord.cs
- HttpAsyncResult.cs
- ToolStripDropDownItem.cs
- GenericRootAutomationPeer.cs
- Events.cs
- HyperLink.cs
- VirtualPathUtility.cs
- OletxDependentTransaction.cs
- DataGrid.cs
- ErrorRuntimeConfig.cs
- SystemIPv6InterfaceProperties.cs
- NativeWrapper.cs
- TextEditorTables.cs
- Trace.cs
- XmlSchemaSimpleTypeUnion.cs
- LogWriteRestartAreaState.cs
- XmlUtil.cs
- ImageSource.cs
- SafeBitVector32.cs
- xmlfixedPageInfo.cs
- GraphicsContext.cs
- AutoResetEvent.cs
- AnimationStorage.cs
- _emptywebproxy.cs
- SqlXml.cs
- TreeNodeStyle.cs
- ListViewContainer.cs
- CommonGetThemePartSize.cs
- FontConverter.cs
- TrackingDataItem.cs
- basevalidator.cs
- UIElement.cs
- UserMapPath.cs
- MimeParameter.cs
- FileFormatException.cs
- ZipIOExtraFieldElement.cs
- ISAPIApplicationHost.cs
- WebControl.cs
- NameValueFileSectionHandler.cs
- ToolStripTextBox.cs
- ListBoxAutomationPeer.cs
- EndpointDiscoveryMetadata11.cs
- HttpCookiesSection.cs
- LinqDataSourceStatusEventArgs.cs
- WebPartDescription.cs
- FacetDescriptionElement.cs
- ResourceProperty.cs
- ComponentResourceKey.cs
- MatchAllMessageFilter.cs
- CuspData.cs
- WindowsUpDown.cs
- Constants.cs
- EncryptedType.cs
- UnmanagedMemoryStream.cs
- TraceUtility.cs
- MasterPage.cs
- BrowserDefinition.cs
- UnsafeMethods.cs
- AliasGenerator.cs
- CompilationPass2TaskInternal.cs
- AdCreatedEventArgs.cs
- DbBuffer.cs
- GradientStop.cs
- ApplicationDirectoryMembershipCondition.cs
- NamedPipeConnectionPool.cs
- CompilerWrapper.cs
- TemplatedMailWebEventProvider.cs
- NameValueConfigurationCollection.cs
- MSAAEventDispatcher.cs
- InArgumentConverter.cs
- BinaryObjectInfo.cs
- BaseValidator.cs
- DocumentApplicationJournalEntry.cs
- XmlSchemaSimpleContentRestriction.cs
- UnionCodeGroup.cs
- XamlParser.cs
- OrderByQueryOptionExpression.cs
- BinarySecretSecurityToken.cs
- SqlGenericUtil.cs
- Formatter.cs
- ClientProxyGenerator.cs
- BinaryMessageEncodingElement.cs
- GlyphRunDrawing.cs
- _emptywebproxy.cs
- PeerNameRegistration.cs
- MsmqIntegrationValidationBehavior.cs
- DmlSqlGenerator.cs
- DataObjectFieldAttribute.cs
- SingleConverter.cs
- Console.cs
- BindingRestrictions.cs