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
- DynamicRenderer.cs
- FileLevelControlBuilderAttribute.cs
- OneOfTypeConst.cs
- NativeWindow.cs
- DateTimeFormatInfoScanner.cs
- _WebProxyDataBuilder.cs
- Focus.cs
- QueryStringParameter.cs
- TextRenderer.cs
- SignatureHelper.cs
- CallId.cs
- BamlVersionHeader.cs
- ExtentKey.cs
- InitializationEventAttribute.cs
- ObjectReferenceStack.cs
- ListParagraph.cs
- WebPartConnectVerb.cs
- NTAccount.cs
- CheckBoxList.cs
- OdbcError.cs
- PageTheme.cs
- InputProviderSite.cs
- Win32MouseDevice.cs
- ContentFilePart.cs
- EventHandlersStore.cs
- AccessedThroughPropertyAttribute.cs
- XmlLanguageConverter.cs
- Misc.cs
- RenderCapability.cs
- httpstaticobjectscollection.cs
- LayoutExceptionEventArgs.cs
- DataStorage.cs
- TextView.cs
- GridViewCancelEditEventArgs.cs
- RadioButtonRenderer.cs
- WindowsNonControl.cs
- CorePropertiesFilter.cs
- MultipleViewPattern.cs
- ModuleConfigurationInfo.cs
- DataGridViewRow.cs
- SqlNodeAnnotation.cs
- BitmapEffectvisualstate.cs
- MonitorWrapper.cs
- DispatchChannelSink.cs
- PageContentCollection.cs
- OrderedDictionary.cs
- StreamReader.cs
- ToolboxItem.cs
- SettingsAttributeDictionary.cs
- SafeFileMappingHandle.cs
- ValueSerializer.cs
- TypeGeneratedEventArgs.cs
- InvokeMethodActivity.cs
- ContentDisposition.cs
- COM2FontConverter.cs
- VisualCollection.cs
- EditCommandColumn.cs
- DuplicateMessageDetector.cs
- GridItemPattern.cs
- StylusPointCollection.cs
- MutexSecurity.cs
- UnsafeNativeMethods.cs
- Figure.cs
- NetStream.cs
- WhereQueryOperator.cs
- Grant.cs
- RangeEnumerable.cs
- LineInfo.cs
- EncoderExceptionFallback.cs
- QEncodedStream.cs
- CustomLineCap.cs
- ExpressionEditor.cs
- WS2007HttpBindingElement.cs
- AutoResetEvent.cs
- EncryptedPackage.cs
- BookmarkList.cs
- XmlDocumentFragment.cs
- BulletChrome.cs
- PointCollectionValueSerializer.cs
- DependencyProperty.cs
- RowToFieldTransformer.cs
- ETagAttribute.cs
- SystemGatewayIPAddressInformation.cs
- Grant.cs
- WindowsUpDown.cs
- ProbeRequestResponseAsyncResult.cs
- ToolStrip.cs
- BoundColumn.cs
- ServerIdentity.cs
- ManagementInstaller.cs
- AttachmentCollection.cs
- WebPartConnectionsCancelEventArgs.cs
- KeyboardDevice.cs
- ImageSourceValueSerializer.cs
- StringPropertyBuilder.cs
- ToolstripProfessionalRenderer.cs
- InputScopeManager.cs
- ProgressiveCrcCalculatingStream.cs
- XmlSchemaFacet.cs
- MemberHolder.cs