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
- Control.cs
- CellParagraph.cs
- ScrollEvent.cs
- MtomMessageEncoder.cs
- IMembershipProvider.cs
- __ComObject.cs
- WeakReference.cs
- DeflateStream.cs
- TreeNodeBindingDepthConverter.cs
- RayHitTestParameters.cs
- ObjectAnimationBase.cs
- Int32Animation.cs
- StringConverter.cs
- VisualProxy.cs
- NameValueCollection.cs
- ConfigurationValidatorBase.cs
- FlowDocumentReader.cs
- RadioButtonList.cs
- PresentationTraceSources.cs
- PrintEvent.cs
- HttpProfileBase.cs
- ContextMenuAutomationPeer.cs
- QueryGeneratorBase.cs
- InstanceDescriptor.cs
- RequestQueue.cs
- BitmapScalingModeValidation.cs
- AQNBuilder.cs
- Attributes.cs
- FileSystemInfo.cs
- DesigntimeLicenseContextSerializer.cs
- Trigger.cs
- XmlQualifiedName.cs
- ReflectionServiceProvider.cs
- TextEditorContextMenu.cs
- AccessDataSourceView.cs
- GlyphInfoList.cs
- DrawingImage.cs
- ProfileBuildProvider.cs
- PaperSource.cs
- SqlStatistics.cs
- SiteMapDataSource.cs
- Pkcs9Attribute.cs
- EncryptedPackage.cs
- RectangleHotSpot.cs
- TextEditorSpelling.cs
- _BufferOffsetSize.cs
- RoleGroupCollection.cs
- FatalException.cs
- PriorityQueue.cs
- contentDescriptor.cs
- templategroup.cs
- HttpModuleActionCollection.cs
- CacheSection.cs
- RootBrowserWindowAutomationPeer.cs
- LineUtil.cs
- XmlTextEncoder.cs
- XmlComplianceUtil.cs
- MultipleFilterMatchesException.cs
- Route.cs
- PathData.cs
- XmlIgnoreAttribute.cs
- SoapHttpTransportImporter.cs
- DataBindEngine.cs
- XmlStringTable.cs
- DrawingGroup.cs
- ProcessProtocolHandler.cs
- ListViewPagedDataSource.cs
- StateManagedCollection.cs
- SystemIcmpV4Statistics.cs
- ButtonRenderer.cs
- SafeNativeMethods.cs
- RowUpdatedEventArgs.cs
- OdbcException.cs
- CellLabel.cs
- DragDropManager.cs
- TextMetrics.cs
- _ShellExpression.cs
- ClientTargetCollection.cs
- OperationContext.cs
- WebPartChrome.cs
- WindowsStatusBar.cs
- TextServicesManager.cs
- OutOfProcStateClientManager.cs
- WindowsPrincipal.cs
- DrawingBrush.cs
- EntityDataSourceState.cs
- ControlPersister.cs
- MessageRpc.cs
- SQlBooleanStorage.cs
- ProcessHostFactoryHelper.cs
- controlskin.cs
- PropertyPushdownHelper.cs
- GridViewUpdateEventArgs.cs
- XmlNode.cs
- BaseProcessor.cs
- CheckBoxFlatAdapter.cs
- RoutingConfiguration.cs
- SudsParser.cs
- Base64Encoder.cs
- GenericTypeParameterBuilder.cs