Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / Xml / System / Xml / XPath / Internal / followingsibling.cs / 1 / followingsibling.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //----------------------------------------------------------------------------- namespace MS.Internal.Xml.XPath { using System; using System.Xml; using System.Xml.XPath; using System.Diagnostics; using System.Collections.Generic; using StackNav = ClonableStack; internal sealed class FollSiblingQuery : BaseAxisQuery { StackNav elementStk; List parentStk; XPathNavigator nextInput; public FollSiblingQuery(Query qyInput, string name, string prefix, XPathNodeType type) : base (qyInput, name, prefix, type) { this.elementStk = new StackNav(); this.parentStk = new List (); } private FollSiblingQuery(FollSiblingQuery other) : base(other) { this.elementStk = other.elementStk.Clone(); this.parentStk = new List (other.parentStk); this.nextInput = Clone(other.nextInput); } public override void Reset() { elementStk.Clear(); parentStk.Clear(); nextInput = null; base.Reset(); } private bool Visited(XPathNavigator nav) { XPathNavigator parent = nav.Clone(); parent.MoveToParent(); for (int i = 0; i < parentStk.Count; i++) { if (parent.IsSamePosition(parentStk[i])) { return true; } } parentStk.Add(parent); return false; } private XPathNavigator FetchInput() { XPathNavigator input; do { input = qyInput.Advance(); if (input == null) { return null; } } while (Visited(input)); return input.Clone(); } public override XPathNavigator Advance() { while (true) { if (currentNode == null) { if (nextInput == null) { nextInput = FetchInput(); // This can happen at the begining and at the end } if (elementStk.Count == 0) { if (nextInput == null) { return null; } currentNode = nextInput; nextInput = FetchInput(); } else { currentNode = elementStk.Pop(); } } while (currentNode.IsDescendant(nextInput)) { elementStk.Push(currentNode); currentNode = nextInput; nextInput = qyInput.Advance(); if (nextInput != null) { nextInput = nextInput.Clone(); } } while (currentNode.MoveToNext()) { if (matches(currentNode)) { position++; return currentNode; } } currentNode = null; } } // Advance public override XPathNodeIterator Clone() { return new FollSiblingQuery(this); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // // Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //----------------------------------------------------------------------------- namespace MS.Internal.Xml.XPath { using System; using System.Xml; using System.Xml.XPath; using System.Diagnostics; using System.Collections.Generic; using StackNav = ClonableStack; internal sealed class FollSiblingQuery : BaseAxisQuery { StackNav elementStk; List parentStk; XPathNavigator nextInput; public FollSiblingQuery(Query qyInput, string name, string prefix, XPathNodeType type) : base (qyInput, name, prefix, type) { this.elementStk = new StackNav(); this.parentStk = new List (); } private FollSiblingQuery(FollSiblingQuery other) : base(other) { this.elementStk = other.elementStk.Clone(); this.parentStk = new List (other.parentStk); this.nextInput = Clone(other.nextInput); } public override void Reset() { elementStk.Clear(); parentStk.Clear(); nextInput = null; base.Reset(); } private bool Visited(XPathNavigator nav) { XPathNavigator parent = nav.Clone(); parent.MoveToParent(); for (int i = 0; i < parentStk.Count; i++) { if (parent.IsSamePosition(parentStk[i])) { return true; } } parentStk.Add(parent); return false; } private XPathNavigator FetchInput() { XPathNavigator input; do { input = qyInput.Advance(); if (input == null) { return null; } } while (Visited(input)); return input.Clone(); } public override XPathNavigator Advance() { while (true) { if (currentNode == null) { if (nextInput == null) { nextInput = FetchInput(); // This can happen at the begining and at the end } if (elementStk.Count == 0) { if (nextInput == null) { return null; } currentNode = nextInput; nextInput = FetchInput(); } else { currentNode = elementStk.Pop(); } } while (currentNode.IsDescendant(nextInput)) { elementStk.Push(currentNode); currentNode = nextInput; nextInput = qyInput.Advance(); if (nextInput != null) { nextInput = nextInput.Clone(); } } while (currentNode.MoveToNext()) { if (matches(currentNode)) { position++; return currentNode; } } currentNode = null; } } // Advance public override XPathNodeIterator Clone() { return new FollSiblingQuery(this); } } } // 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
- DeferredTextReference.cs
- SQLMoneyStorage.cs
- ClientSettingsSection.cs
- RawStylusInput.cs
- SqlCachedBuffer.cs
- ObjectAssociationEndMapping.cs
- Console.cs
- InkCanvasInnerCanvas.cs
- Stacktrace.cs
- FixUpCollection.cs
- Int32AnimationUsingKeyFrames.cs
- BlurBitmapEffect.cs
- DataSpaceManager.cs
- ZipIOLocalFileBlock.cs
- LinkLabel.cs
- ReadingWritingEntityEventArgs.cs
- WebServiceAttribute.cs
- WhileDesigner.cs
- WbmpConverter.cs
- ContractUtils.cs
- PriorityBinding.cs
- HttpProfileGroupBase.cs
- ManagementScope.cs
- IdentityReference.cs
- HttpRawResponse.cs
- SqlDataSourceQuery.cs
- Typography.cs
- TextOptionsInternal.cs
- SQLInt32Storage.cs
- HasCopySemanticsAttribute.cs
- ClientSettingsSection.cs
- UIElementHelper.cs
- StorageEntitySetMapping.cs
- TextAutomationPeer.cs
- Subtree.cs
- ConnectionAcceptor.cs
- PolicyStatement.cs
- ListBoxChrome.cs
- GcSettings.cs
- XPathNavigator.cs
- TdsEnums.cs
- DataGridLinkButton.cs
- ContentType.cs
- SelectedDatesCollection.cs
- TraceProvider.cs
- EmptyEnumerator.cs
- NominalTypeEliminator.cs
- XDeferredAxisSource.cs
- ControlCollection.cs
- CollectionBuilder.cs
- SiteMapDataSourceView.cs
- XmlReader.cs
- FontUnit.cs
- ObjectDataSource.cs
- Match.cs
- CodeDomConfigurationHandler.cs
- NavigationPropertyAccessor.cs
- DataProtection.cs
- AnnotationComponentManager.cs
- CollectionViewGroupInternal.cs
- ImageList.cs
- SmiMetaData.cs
- OdbcConnectionString.cs
- ConnectionManagementElement.cs
- WorkflowInstanceAbortedRecord.cs
- HeaderedContentControl.cs
- AcceptorSessionSymmetricTransportSecurityProtocol.cs
- _IPv4Address.cs
- DesignerSelectionListAdapter.cs
- SQLGuid.cs
- ConfigXmlReader.cs
- WebBrowserUriTypeConverter.cs
- TextSpan.cs
- DataControlLinkButton.cs
- RectAnimationUsingKeyFrames.cs
- VariableDesigner.xaml.cs
- XmlSchemaNotation.cs
- MessageBox.cs
- SslStreamSecurityBindingElement.cs
- ScriptResourceHandler.cs
- Avt.cs
- PauseStoryboard.cs
- StreamSecurityUpgradeInitiator.cs
- UniqueEventHelper.cs
- CodeExporter.cs
- CodeDelegateCreateExpression.cs
- XmlEntity.cs
- XmlCharacterData.cs
- AddInIpcChannel.cs
- SqlTriggerAttribute.cs
- CopyCodeAction.cs
- WebPartEventArgs.cs
- ClickablePoint.cs
- prefixendpointaddressmessagefilter.cs
- GeneralTransform2DTo3D.cs
- ButtonChrome.cs
- ResourceKey.cs
- RecognizedPhrase.cs
- ProfilePropertySettings.cs
- DocumentSequence.cs