Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Xml / System / Xml / Dom / XPathNodeList.cs / 1305376 / 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
- TraceSection.cs
- Clipboard.cs
- SoapFormatExtensions.cs
- BitmapEffectGroup.cs
- RecognizedAudio.cs
- xml.cs
- RegexCharClass.cs
- CollectionViewProxy.cs
- SchemaImporterExtensionElementCollection.cs
- InvokeGenerator.cs
- Helpers.cs
- XsltLoader.cs
- Size3D.cs
- SessionEndingCancelEventArgs.cs
- SqlTypeSystemProvider.cs
- WebPartExportVerb.cs
- ValidationPropertyAttribute.cs
- EntityContainerRelationshipSetEnd.cs
- AspCompat.cs
- BufferedReadStream.cs
- ToolStripItemImageRenderEventArgs.cs
- FactoryRecord.cs
- PermissionSetTriple.cs
- wmiprovider.cs
- CompoundFileStorageReference.cs
- WizardPanel.cs
- GraphicsPath.cs
- XmlDigitalSignatureProcessor.cs
- EntityDataSourceStatementEditorForm.cs
- SystemUnicastIPAddressInformation.cs
- CopyAttributesAction.cs
- XPathNavigatorReader.cs
- ScaleTransform.cs
- EmptyStringExpandableObjectConverter.cs
- AdapterUtil.cs
- TraceSection.cs
- FunctionNode.cs
- SecUtil.cs
- ClientScriptManager.cs
- CommonDialog.cs
- DiscriminatorMap.cs
- SoapAttributes.cs
- PhonemeEventArgs.cs
- ContextProperty.cs
- BuiltInExpr.cs
- EmissiveMaterial.cs
- MetabaseServerConfig.cs
- ToolStripHighContrastRenderer.cs
- TraceSwitch.cs
- BrowserDefinition.cs
- TableSectionStyle.cs
- FormattedTextSymbols.cs
- SoapExtensionImporter.cs
- DocumentEventArgs.cs
- AutomationProperty.cs
- State.cs
- ManipulationDevice.cs
- BamlTreeNode.cs
- validation.cs
- DirectoryInfo.cs
- TypeInformation.cs
- DataControlCommands.cs
- ReceiveSecurityHeaderElementManager.cs
- StylusCollection.cs
- Msec.cs
- TypedDataSetSchemaImporterExtension.cs
- DataObjectAttribute.cs
- DirectoryInfo.cs
- SchemaImporter.cs
- ExtentKey.cs
- ToolBarOverflowPanel.cs
- BitmapEffectDrawing.cs
- GZipDecoder.cs
- UnsafeNativeMethods.cs
- Attributes.cs
- ConfigXmlText.cs
- WebPartMovingEventArgs.cs
- InkCanvasSelection.cs
- HwndHostAutomationPeer.cs
- HttpPostedFile.cs
- SqlProviderManifest.cs
- SQLInt64.cs
- OLEDB_Enum.cs
- MessagePartSpecification.cs
- ConfigXmlText.cs
- ObjectQueryState.cs
- HttpResponseHeader.cs
- ContentPathSegment.cs
- PointLight.cs
- ProfileSection.cs
- TakeOrSkipQueryOperator.cs
- WizardPanel.cs
- DataGridViewCellCollection.cs
- XmlSchema.cs
- CachedCompositeFamily.cs
- Currency.cs
- SessionStateSection.cs
- DbConnectionPoolGroupProviderInfo.cs
- __TransparentProxy.cs
- PickBranchDesigner.xaml.cs