Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / Xml / System / Xml / Dom / XPathNodeList.cs / 1 / XPathNodeList.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //----------------------------------------------------------------------------- namespace System.Xml { using System.Xml.XPath; using System.Diagnostics; using System.Collections; using System.Collections.Generic; internal class XPathNodeList: XmlNodeList { Listlist; XPathNodeIterator nodeIterator; bool done; public XPathNodeList(XPathNodeIterator nodeIterator) { this.nodeIterator = nodeIterator; this.list = new List (); this.done = false; } public override int Count { get { if (! done) { ReadUntil(Int32.MaxValue); } return list.Count; } } private static readonly object[] nullparams = {}; private XmlNode GetNode(XPathNavigator n) { IHasXmlNode iHasNode = (IHasXmlNode) n; return iHasNode.GetNode(); } internal int ReadUntil(int index) { int count = list.Count; while (! done && count <= index) { if (nodeIterator.MoveNext()) { XmlNode n = GetNode(nodeIterator.Current); if (n != null) { list.Add(n); count++; } } else { done = true; break; } } return count; } public override XmlNode Item(int index) { if (list.Count <= index) { ReadUntil(index); } if (index < 0 || list.Count <= index) { return null; } return list[index]; } public override IEnumerator GetEnumerator() { return new XmlNodeListEnumerator(this); } } internal class XmlNodeListEnumerator : IEnumerator { XPathNodeList list; int index; bool valid; public XmlNodeListEnumerator(XPathNodeList list) { this.list = list; this.index = -1; this.valid = false; } public void Reset() { index = -1; } public bool MoveNext() { index++; int count = list.ReadUntil(index + 1); // read past for delete-node case if (count - 1 < index) { return false; } valid = (list[index] != null); return valid; } public object Current { get { if (valid) { return list[index]; } return null; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // // Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //----------------------------------------------------------------------------- namespace System.Xml { using System.Xml.XPath; using System.Diagnostics; using System.Collections; using System.Collections.Generic; internal class XPathNodeList: XmlNodeList { Listlist; XPathNodeIterator nodeIterator; bool done; public XPathNodeList(XPathNodeIterator nodeIterator) { this.nodeIterator = nodeIterator; this.list = new List (); this.done = false; } public override int Count { get { if (! done) { ReadUntil(Int32.MaxValue); } return list.Count; } } private static readonly object[] nullparams = {}; private XmlNode GetNode(XPathNavigator n) { IHasXmlNode iHasNode = (IHasXmlNode) n; return iHasNode.GetNode(); } internal int ReadUntil(int index) { int count = list.Count; while (! done && count <= index) { if (nodeIterator.MoveNext()) { XmlNode n = GetNode(nodeIterator.Current); if (n != null) { list.Add(n); count++; } } else { done = true; break; } } return count; } public override XmlNode Item(int index) { if (list.Count <= index) { ReadUntil(index); } if (index < 0 || list.Count <= index) { return null; } return list[index]; } public override IEnumerator GetEnumerator() { return new XmlNodeListEnumerator(this); } } internal class XmlNodeListEnumerator : IEnumerator { XPathNodeList list; int index; bool valid; public XmlNodeListEnumerator(XPathNodeList list) { this.list = list; this.index = -1; this.valid = false; } public void Reset() { index = -1; } public bool MoveNext() { index++; int count = list.ReadUntil(index + 1); // read past for delete-node case if (count - 1 < index) { return false; } valid = (list[index] != null); return valid; } public object Current { get { if (valid) { return list[index]; } return null; } } } } // 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
- XpsSerializationManagerAsync.cs
- ReadOnlyDictionary.cs
- EntityType.cs
- WindowsSolidBrush.cs
- IDispatchConstantAttribute.cs
- BindUriHelper.cs
- EntityTransaction.cs
- InputBuffer.cs
- ConfigurationSectionGroupCollection.cs
- TcpConnectionPoolSettings.cs
- IsolatedStorageFilePermission.cs
- ToolTipAutomationPeer.cs
- ZipFileInfo.cs
- counter.cs
- XmlSerializableReader.cs
- DataStorage.cs
- ViewDesigner.cs
- ClientUriBehavior.cs
- PhysicalOps.cs
- GrabHandleGlyph.cs
- LicenseContext.cs
- ColorPalette.cs
- future.cs
- TableSectionStyle.cs
- TextParagraphView.cs
- TraceHandlerErrorFormatter.cs
- ConfigXmlWhitespace.cs
- WinFormsUtils.cs
- DiagnosticTraceSource.cs
- XmlWriterSettings.cs
- StructuralCache.cs
- ArcSegment.cs
- ArglessEventHandlerProxy.cs
- RuntimeResourceSet.cs
- DeploymentExceptionMapper.cs
- InternalRelationshipCollection.cs
- PageCatalogPartDesigner.cs
- XPathCompileException.cs
- DragStartedEventArgs.cs
- AssemblyCollection.cs
- LeaseManager.cs
- PointKeyFrameCollection.cs
- DataDocumentXPathNavigator.cs
- RegionData.cs
- _SslState.cs
- DefaultValueTypeConverter.cs
- XmlNavigatorStack.cs
- messageonlyhwndwrapper.cs
- BindingSource.cs
- MatrixAnimationUsingKeyFrames.cs
- BooleanConverter.cs
- DispatcherExceptionFilterEventArgs.cs
- XmlTextReader.cs
- AttributeSetAction.cs
- InternalConfigRoot.cs
- AddInControllerImpl.cs
- EntityViewGenerationAttribute.cs
- EntityDataSourceColumn.cs
- ObsoleteAttribute.cs
- Partitioner.cs
- ListViewUpdateEventArgs.cs
- MemberProjectionIndex.cs
- CommandManager.cs
- Events.cs
- Size.cs
- TiffBitmapDecoder.cs
- _UncName.cs
- OdbcHandle.cs
- WorkflowInstanceExtensionCollection.cs
- CollectionViewProxy.cs
- RadialGradientBrush.cs
- ScrollBar.cs
- DrawingDrawingContext.cs
- SoapTypeAttribute.cs
- PeerNode.cs
- DataListItemCollection.cs
- XmlChoiceIdentifierAttribute.cs
- SiteMapHierarchicalDataSourceView.cs
- AttachedPropertyMethodSelector.cs
- DbConnectionFactory.cs
- EndpointInstanceProvider.cs
- Win32.cs
- DiscoveryReferences.cs
- XmlUrlResolver.cs
- AutoGeneratedField.cs
- _FtpControlStream.cs
- XmlTextReaderImplHelpers.cs
- ImageListStreamer.cs
- TypeConverters.cs
- WebPartManagerDesigner.cs
- PartialToken.cs
- SqlCommand.cs
- StyleBamlTreeBuilder.cs
- HtmlEncodedRawTextWriter.cs
- NameValueCollection.cs
- ScrollBarAutomationPeer.cs
- DuplicateWaitObjectException.cs
- SafeNativeMethods.cs
- ToolStripItemRenderEventArgs.cs
- InstanceLockException.cs