Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / XmlUtils / System / Xml / Xsl / XsltOld / ForEachAction.cs / 1305376 / ForEachAction.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //----------------------------------------------------------------------------- namespace System.Xml.Xsl.XsltOld { using Res = System.Xml.Utils.Res; using System; using System.Diagnostics; using System.Collections; using System.Xml; using System.Xml.XPath; internal class ForEachAction : ContainerAction { private const int ProcessedSort = 2; private const int ProcessNextNode = 3; private const int PositionAdvanced = 4; private const int ContentsProcessed = 5; private int selectKey = Compiler.InvalidQueryKey; private ContainerAction sortContainer; internal override void Compile(Compiler compiler) { CompileAttributes(compiler); CheckRequiredAttribute(compiler, selectKey != Compiler.InvalidQueryKey, "select"); compiler.CanHaveApplyImports = false; if (compiler.Recurse()) { CompileSortElements(compiler); CompileTemplate(compiler); compiler.ToParent(); } } internal override bool CompileAttribute(Compiler compiler) { string name = compiler.Input.LocalName; string value = compiler.Input.Value; if (Ref.Equal(name, compiler.Atoms.Select)) { this.selectKey = compiler.AddQuery(value); } else { return false; } return true; } internal override void Execute(Processor processor, ActionFrame frame) { Debug.Assert(processor != null && frame != null); switch (frame.State) { case Initialized: if (sortContainer != null) { processor.InitSortArray(); processor.PushActionFrame(sortContainer, frame.NodeSet); frame.State = ProcessedSort; break; } goto case ProcessedSort; case ProcessedSort: frame.InitNewNodeSet(processor.StartQuery(frame.NodeSet, this.selectKey)); if (sortContainer != null) { Debug.Assert(processor.SortArray.Count != 0); frame.SortNewNodeSet(processor, processor.SortArray); } frame.State = ProcessNextNode; goto case ProcessNextNode; case ProcessNextNode: Debug.Assert(frame.State == ProcessNextNode); Debug.Assert(frame.NewNodeSet != null); if (frame.NewNextNode(processor)) { frame.State = PositionAdvanced; goto case PositionAdvanced; } else { frame.Finished(); break; } case PositionAdvanced: processor.PushActionFrame(frame, frame.NewNodeSet); frame.State = ContentsProcessed; break; case ContentsProcessed: frame.State = ProcessNextNode; goto case ProcessNextNode; } } protected void CompileSortElements(Compiler compiler) { NavigatorInput input = compiler.Input; do { switch(input.NodeType) { case XPathNodeType.Element: if (Ref.Equal(input.NamespaceURI, input.Atoms.UriXsl) && Ref.Equal(input.LocalName, input.Atoms.Sort)) { if (sortContainer == null) { sortContainer = new ContainerAction(); } sortContainer.AddAction(compiler.CreateSortAction()); continue; } return; case XPathNodeType.Text: return; case XPathNodeType.SignificantWhitespace: this.AddEvent(compiler.CreateTextEvent()); continue; default : continue; } } while (input.Advance()); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //----------------------------------------------------------------------------- namespace System.Xml.Xsl.XsltOld { using Res = System.Xml.Utils.Res; using System; using System.Diagnostics; using System.Collections; using System.Xml; using System.Xml.XPath; internal class ForEachAction : ContainerAction { private const int ProcessedSort = 2; private const int ProcessNextNode = 3; private const int PositionAdvanced = 4; private const int ContentsProcessed = 5; private int selectKey = Compiler.InvalidQueryKey; private ContainerAction sortContainer; internal override void Compile(Compiler compiler) { CompileAttributes(compiler); CheckRequiredAttribute(compiler, selectKey != Compiler.InvalidQueryKey, "select"); compiler.CanHaveApplyImports = false; if (compiler.Recurse()) { CompileSortElements(compiler); CompileTemplate(compiler); compiler.ToParent(); } } internal override bool CompileAttribute(Compiler compiler) { string name = compiler.Input.LocalName; string value = compiler.Input.Value; if (Ref.Equal(name, compiler.Atoms.Select)) { this.selectKey = compiler.AddQuery(value); } else { return false; } return true; } internal override void Execute(Processor processor, ActionFrame frame) { Debug.Assert(processor != null && frame != null); switch (frame.State) { case Initialized: if (sortContainer != null) { processor.InitSortArray(); processor.PushActionFrame(sortContainer, frame.NodeSet); frame.State = ProcessedSort; break; } goto case ProcessedSort; case ProcessedSort: frame.InitNewNodeSet(processor.StartQuery(frame.NodeSet, this.selectKey)); if (sortContainer != null) { Debug.Assert(processor.SortArray.Count != 0); frame.SortNewNodeSet(processor, processor.SortArray); } frame.State = ProcessNextNode; goto case ProcessNextNode; case ProcessNextNode: Debug.Assert(frame.State == ProcessNextNode); Debug.Assert(frame.NewNodeSet != null); if (frame.NewNextNode(processor)) { frame.State = PositionAdvanced; goto case PositionAdvanced; } else { frame.Finished(); break; } case PositionAdvanced: processor.PushActionFrame(frame, frame.NewNodeSet); frame.State = ContentsProcessed; break; case ContentsProcessed: frame.State = ProcessNextNode; goto case ProcessNextNode; } } protected void CompileSortElements(Compiler compiler) { NavigatorInput input = compiler.Input; do { switch(input.NodeType) { case XPathNodeType.Element: if (Ref.Equal(input.NamespaceURI, input.Atoms.UriXsl) && Ref.Equal(input.LocalName, input.Atoms.Sort)) { if (sortContainer == null) { sortContainer = new ContainerAction(); } sortContainer.AddAction(compiler.CreateSortAction()); continue; } return; case XPathNodeType.Text: return; case XPathNodeType.SignificantWhitespace: this.AddEvent(compiler.CreateTextEvent()); continue; default : continue; } } while (input.Advance()); } } } // 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
- ResourceDictionaryCollection.cs
- WebServiceMethodData.cs
- GeometryDrawing.cs
- ToolStripButton.cs
- DataGridViewHitTestInfo.cs
- ItemTypeToolStripMenuItem.cs
- WindowsFont.cs
- RequiredFieldValidator.cs
- DependencyObject.cs
- TraversalRequest.cs
- AutomationTextAttribute.cs
- IPHostEntry.cs
- ReferencedType.cs
- InputScopeAttribute.cs
- ItemCheckedEvent.cs
- securestring.cs
- Typeface.cs
- HtmlInputHidden.cs
- TransformerTypeCollection.cs
- BitmapEffectInput.cs
- ScriptHandlerFactory.cs
- TypeNameConverter.cs
- TreeViewAutomationPeer.cs
- PerfCounters.cs
- _AcceptOverlappedAsyncResult.cs
- WebControl.cs
- XmlAutoDetectWriter.cs
- WindowInteropHelper.cs
- Html32TextWriter.cs
- ComAdminInterfaces.cs
- ReadContentAsBinaryHelper.cs
- ExpressionConverter.cs
- PrincipalPermission.cs
- UriSection.cs
- CoreChannel.cs
- WebReferencesBuildProvider.cs
- LinqDataSourceUpdateEventArgs.cs
- SafeFileMapViewHandle.cs
- WebPartConnectionsCancelVerb.cs
- DesignTimeResourceProviderFactoryAttribute.cs
- BitArray.cs
- FormsAuthenticationConfiguration.cs
- ConfigXmlDocument.cs
- XPathQilFactory.cs
- RoutedEventHandlerInfo.cs
- Int32RectValueSerializer.cs
- HostingEnvironmentException.cs
- EncryptedData.cs
- ListBindingConverter.cs
- AttachedPropertyBrowsableForTypeAttribute.cs
- CodeObjectCreateExpression.cs
- NetworkCredential.cs
- ComboBoxAutomationPeer.cs
- DrawingContextWalker.cs
- SamlAuthorizationDecisionStatement.cs
- ControlCachePolicy.cs
- TargetException.cs
- SqlDependencyListener.cs
- Assert.cs
- PageSetupDialog.cs
- ReliabilityContractAttribute.cs
- ModelService.cs
- DropDownButton.cs
- LinkTarget.cs
- _SafeNetHandles.cs
- NameValuePair.cs
- unsafeIndexingFilterStream.cs
- ValueQuery.cs
- SHA384.cs
- AxImporter.cs
- TransactionFilter.cs
- SessionParameter.cs
- PartialCachingAttribute.cs
- TextEditorTyping.cs
- ImageCollectionCodeDomSerializer.cs
- AssemblyName.cs
- EntityViewGenerator.cs
- EasingKeyFrames.cs
- TypedRowHandler.cs
- Solver.cs
- TextEditorThreadLocalStore.cs
- MailDefinitionBodyFileNameEditor.cs
- TextSelection.cs
- PrinterResolution.cs
- XPathBinder.cs
- FocusTracker.cs
- AmbientLight.cs
- MsmqAppDomainProtocolHandler.cs
- sqlser.cs
- IntegerFacetDescriptionElement.cs
- CompiledRegexRunner.cs
- ToolStripManager.cs
- Thread.cs
- XmlSchemaDocumentation.cs
- XPathAncestorQuery.cs
- DeferredElementTreeState.cs
- NonDualMessageSecurityOverHttpElement.cs
- EmptyQuery.cs
- ToolStripSettings.cs
- MemberInitExpression.cs