Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- IUnknownConstantAttribute.cs
- MappingSource.cs
- SchemaObjectWriter.cs
- ScriptingJsonSerializationSection.cs
- HashMembershipCondition.cs
- ApplicationSecurityManager.cs
- ConfigurationValidatorAttribute.cs
- Int64Animation.cs
- PathSegmentCollection.cs
- PointCollectionValueSerializer.cs
- MessageBox.cs
- DetailsViewDeleteEventArgs.cs
- PerSessionInstanceContextProvider.cs
- ConfigXmlElement.cs
- StackBuilderSink.cs
- XmlResolver.cs
- DynamicArgumentDesigner.xaml.cs
- ClientEventManager.cs
- SafeHandle.cs
- AppSettingsSection.cs
- DataGridViewRowsRemovedEventArgs.cs
- VectorKeyFrameCollection.cs
- TdsParserSessionPool.cs
- SQLStringStorage.cs
- XamlToRtfWriter.cs
- SizeConverter.cs
- RelatedCurrencyManager.cs
- EntityConnectionStringBuilder.cs
- ReadOnlyNameValueCollection.cs
- HtmlElement.cs
- WSUtilitySpecificationVersion.cs
- WebPartsSection.cs
- WeakReferenceKey.cs
- LicFileLicenseProvider.cs
- ComponentResourceKey.cs
- MenuAutomationPeer.cs
- SqlDuplicator.cs
- ZipIOEndOfCentralDirectoryBlock.cs
- MappingItemCollection.cs
- PackageRelationshipCollection.cs
- MimeTypeMapper.cs
- PathSegmentCollection.cs
- AtomContentProperty.cs
- TerminatorSinks.cs
- Compress.cs
- RemotingConfiguration.cs
- HtmlElementCollection.cs
- X509ChainPolicy.cs
- ProjectionPruner.cs
- XMLDiffLoader.cs
- StandardOleMarshalObject.cs
- DoubleAnimationUsingPath.cs
- XmlWriter.cs
- DesignerCatalogPartChrome.cs
- LinkDescriptor.cs
- SiteOfOriginPart.cs
- Pen.cs
- MessageFilterException.cs
- TimeSpan.cs
- Blend.cs
- InstanceDataCollection.cs
- DocumentPageView.cs
- GeneralTransform.cs
- StopStoryboard.cs
- DelayLoadType.cs
- MethodInfo.cs
- DesignerAttribute.cs
- SimpleApplicationHost.cs
- SystemIcons.cs
- CmsInterop.cs
- FontStretches.cs
- WebPartConnectionsCancelVerb.cs
- ExitEventArgs.cs
- PlatformCulture.cs
- ListViewItem.cs
- FileStream.cs
- DescendentsWalker.cs
- CommandBinding.cs
- ApplicationBuildProvider.cs
- Membership.cs
- RectangleConverter.cs
- ImageButton.cs
- TableSectionStyle.cs
- SimpleTypeResolver.cs
- TypeValidationEventArgs.cs
- Main.cs
- MexServiceChannelBuilder.cs
- xamlnodes.cs
- RemotingConfiguration.cs
- NullableDecimalMinMaxAggregationOperator.cs
- XmlTypeAttribute.cs
- PageAsyncTask.cs
- CategoryNameCollection.cs
- ObservableDictionary.cs
- LoginUtil.cs
- DPCustomTypeDescriptor.cs
- SamlSecurityTokenAuthenticator.cs
- WeakRefEnumerator.cs
- DirtyTextRange.cs
- ParameterCollection.cs