Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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
- EntityDataSourceWrapperCollection.cs
- ActivityValidationServices.cs
- COM2TypeInfoProcessor.cs
- SqlParameter.cs
- BaseTreeIterator.cs
- ValueConversionAttribute.cs
- DesignTimeTemplateParser.cs
- DesignerObject.cs
- WebBrowserContainer.cs
- Serialization.cs
- BookmarkTable.cs
- SoapHeaderException.cs
- ErrorFormatter.cs
- VarRefManager.cs
- ToolBarButton.cs
- ObjectDataSourceEventArgs.cs
- SqlInternalConnectionTds.cs
- EventArgs.cs
- FocusTracker.cs
- HybridObjectCache.cs
- ValidationUtility.cs
- HandledEventArgs.cs
- QilPatternVisitor.cs
- MimeImporter.cs
- ExtensionsSection.cs
- ModelToObjectValueConverter.cs
- XmlQualifiedName.cs
- ObjectItemLoadingSessionData.cs
- XmlnsPrefixAttribute.cs
- MULTI_QI.cs
- unsafenativemethodsother.cs
- PropertyDescriptorCollection.cs
- CustomCategoryAttribute.cs
- RegionData.cs
- PopupRoot.cs
- IntegerFacetDescriptionElement.cs
- PermissionAttributes.cs
- ConsoleCancelEventArgs.cs
- SaveFileDialog.cs
- SQLGuidStorage.cs
- SafeBitVector32.cs
- mansign.cs
- XmlLanguage.cs
- ImageListUtils.cs
- XmlBuffer.cs
- SmtpMail.cs
- EncodingConverter.cs
- ServicesExceptionNotHandledEventArgs.cs
- UnsafeNativeMethods.cs
- DesignerActionItem.cs
- Point3DCollectionConverter.cs
- MenuDesigner.cs
- LookupNode.cs
- BufferModeSettings.cs
- BadImageFormatException.cs
- ComplexPropertyEntry.cs
- NumericPagerField.cs
- FileAccessException.cs
- GcSettings.cs
- UIElementPropertyUndoUnit.cs
- DataBinder.cs
- XmlSiteMapProvider.cs
- ResourceCategoryAttribute.cs
- HTMLTextWriter.cs
- SqlServer2KCompatibilityCheck.cs
- WriteFileContext.cs
- DataGridLinkButton.cs
- WebControl.cs
- TransformedBitmap.cs
- SHA1CryptoServiceProvider.cs
- ObjectHelper.cs
- EnumBuilder.cs
- LoginName.cs
- PageStatePersister.cs
- PackageRelationship.cs
- documentsequencetextcontainer.cs
- Message.cs
- XmlSchemaAnnotated.cs
- DbConnectionClosed.cs
- DataRelation.cs
- CommunicationException.cs
- HebrewCalendar.cs
- UserInitiatedNavigationPermission.cs
- HtmlTableCell.cs
- WebServiceParameterData.cs
- ExpressionEditorAttribute.cs
- SoapBinding.cs
- SecurityCriticalDataForSet.cs
- WebServiceErrorEvent.cs
- PhonemeEventArgs.cs
- ExpressionBuilderContext.cs
- MarshalByRefObject.cs
- PagedDataSource.cs
- DeviceContext.cs
- WebHeaderCollection.cs
- LongValidatorAttribute.cs
- XmlQualifiedNameTest.cs
- ExceptQueryOperator.cs
- CopyAction.cs
- InvokeBinder.cs