Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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
- OleDbCommandBuilder.cs
- ComponentGuaranteesAttribute.cs
- WindowsImpersonationContext.cs
- IProvider.cs
- MemberHolder.cs
- UnauthorizedWebPart.cs
- Fx.cs
- externdll.cs
- TreeViewHitTestInfo.cs
- HTMLTagNameToTypeMapper.cs
- BitmapEffect.cs
- ContainerVisual.cs
- NumericPagerField.cs
- Misc.cs
- SoapSchemaImporter.cs
- SchemaSetCompiler.cs
- PrinterResolution.cs
- SqlErrorCollection.cs
- MarshalByRefObject.cs
- XPathEmptyIterator.cs
- KeyboardNavigation.cs
- SurrogateEncoder.cs
- ScriptingScriptResourceHandlerSection.cs
- SettingsPropertyNotFoundException.cs
- FilteredAttributeCollection.cs
- ClientScriptManager.cs
- VectorAnimationUsingKeyFrames.cs
- MasterPageParser.cs
- MatrixTransform.cs
- AppDomainManager.cs
- WpfSharedBamlSchemaContext.cs
- SoundPlayer.cs
- Drawing.cs
- TextRunCacheImp.cs
- HtmlWindowCollection.cs
- SuppressMessageAttribute.cs
- UserControlDesigner.cs
- InstanceStore.cs
- DataGridViewCellStyle.cs
- TypeBuilderInstantiation.cs
- BitmapPalettes.cs
- cookiecontainer.cs
- FrameDimension.cs
- ConfigurationLockCollection.cs
- RequestStatusBarUpdateEventArgs.cs
- QueueProcessor.cs
- StringPropertyBuilder.cs
- StringInfo.cs
- AnimationClock.cs
- arc.cs
- Block.cs
- PropertyGridCommands.cs
- ListSourceHelper.cs
- Cursor.cs
- SchemaElement.cs
- ListViewItem.cs
- NumberFunctions.cs
- ControlCollection.cs
- XmlSchemaSimpleTypeUnion.cs
- SafeUserTokenHandle.cs
- TabletCollection.cs
- TransformGroup.cs
- COMException.cs
- CacheSection.cs
- PrePrepareMethodAttribute.cs
- XmlSchemaSimpleTypeList.cs
- BuilderPropertyEntry.cs
- TemplatePropertyEntry.cs
- DiagnosticsConfiguration.cs
- DataServiceRequestException.cs
- FontWeight.cs
- AppPool.cs
- NonBatchDirectoryCompiler.cs
- AtomContentProperty.cs
- UnsafeNativeMethods.cs
- RefreshEventArgs.cs
- WebPartAddingEventArgs.cs
- RetrieveVirtualItemEventArgs.cs
- EntityDataSourceView.cs
- MetadataItem.cs
- DataGridViewColumnHeaderCell.cs
- ParameterCollectionEditorForm.cs
- SQLUtility.cs
- TreeViewTemplateSelector.cs
- ElementMarkupObject.cs
- GPPOINT.cs
- SecurityDocument.cs
- CompositeControlDesigner.cs
- ServiceDescription.cs
- ResolvedKeyFrameEntry.cs
- GeneralTransform2DTo3DTo2D.cs
- PerformanceCounterCategory.cs
- CommandSet.cs
- TabPanel.cs
- ByteStreamMessageUtility.cs
- ItemChangedEventArgs.cs
- AsyncOperation.cs
- SrgsGrammar.cs
- TransactionChannelFactory.cs
- SearchForVirtualItemEventArgs.cs