Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / XmlUtils / System / Xml / Xsl / QIL / QilScopedVisitor.cs / 1305376 / 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
- ParseNumbers.cs
- SqlClientPermission.cs
- ButtonFieldBase.cs
- WizardPanelChangingEventArgs.cs
- DataGridViewAccessibleObject.cs
- IPEndPoint.cs
- path.cs
- StyleXamlTreeBuilder.cs
- EndPoint.cs
- _OSSOCK.cs
- XMLSyntaxException.cs
- CommandExpr.cs
- XmlWriter.cs
- XmlAnyAttributeAttribute.cs
- ListBox.cs
- Thumb.cs
- LinearKeyFrames.cs
- DocumentOrderComparer.cs
- HttpStaticObjectsCollectionBase.cs
- DocumentSequence.cs
- X509ChainPolicy.cs
- AppSecurityManager.cs
- securitycriticaldataformultiplegetandset.cs
- Token.cs
- ObjectAnimationUsingKeyFrames.cs
- Rethrow.cs
- CompressedStack.cs
- ConnectAlgorithms.cs
- SqlBulkCopyColumnMappingCollection.cs
- DrawingServices.cs
- XmlSchemaAll.cs
- ListBindableAttribute.cs
- CompositeControl.cs
- XmlChildEnumerator.cs
- WebBrowserContainer.cs
- AutomationEventArgs.cs
- OleDbConnectionInternal.cs
- TripleDES.cs
- PropertyChange.cs
- AsyncOperationManager.cs
- ActiveXSite.cs
- BaseValidator.cs
- InputLanguage.cs
- HandleCollector.cs
- AggregateNode.cs
- SystemIPGlobalStatistics.cs
- TableLayoutSettings.cs
- WebServiceReceive.cs
- PreviewPageInfo.cs
- XmlDeclaration.cs
- RequestStatusBarUpdateEventArgs.cs
- LocatorGroup.cs
- DataControlFieldHeaderCell.cs
- InstalledFontCollection.cs
- ADConnectionHelper.cs
- RecognizedPhrase.cs
- SqlDataRecord.cs
- XPathItem.cs
- KeyedHashAlgorithm.cs
- Marshal.cs
- DecimalFormatter.cs
- BamlTreeMap.cs
- PrefixHandle.cs
- ClientProtocol.cs
- SmtpException.cs
- _ListenerResponseStream.cs
- Stroke2.cs
- SetStateEventArgs.cs
- ManagementEventWatcher.cs
- SQLInt64Storage.cs
- ColorConvertedBitmap.cs
- MatrixTransform.cs
- ProjectionPathBuilder.cs
- Baml2006ReaderContext.cs
- XmlEnumAttribute.cs
- ReturnValue.cs
- DbProviderManifest.cs
- BCryptSafeHandles.cs
- ButtonFieldBase.cs
- UnknownWrapper.cs
- LongMinMaxAggregationOperator.cs
- DataFormat.cs
- XmlSchemaInfo.cs
- QuaternionRotation3D.cs
- ResourceAttributes.cs
- StackOverflowException.cs
- TileModeValidation.cs
- PlatformNotSupportedException.cs
- ByteStack.cs
- ExternalException.cs
- StringUtil.cs
- HtmlEncodedRawTextWriter.cs
- HttpContextBase.cs
- XhtmlTextWriter.cs
- KeyProperty.cs
- WebPartEditorOkVerb.cs
- SessionViewState.cs
- GridViewColumn.cs
- LogArchiveSnapshot.cs
- SimpleHandlerFactory.cs