Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Data / System / NewXml / TreeIterator.cs / 1305376 / TreeIterator.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// [....]
// [....]
//-----------------------------------------------------------------------------
#pragma warning disable 618 // ignore obsolete warning about XmlDataDocument
namespace System.Xml {
using System.Diagnostics;
// Iterates over non-attribute nodes
internal sealed class TreeIterator : BaseTreeIterator {
private XmlNode nodeTop;
private XmlNode currentNode;
internal TreeIterator( XmlNode nodeTop ) : base( ((XmlDataDocument)(nodeTop.OwnerDocument)).Mapper ) {
Debug.Assert( nodeTop != null );
this.nodeTop = nodeTop;
this.currentNode = nodeTop;
}
internal override void Reset() {
currentNode = nodeTop;
}
internal override XmlNode CurrentNode {
get {
return currentNode;
}
}
internal override bool Next() {
XmlNode nextNode;
// Try to move to the first child
nextNode = currentNode.FirstChild;
// No children, try next sibling
if ( nextNode != null ) {
currentNode = nextNode;
return true;
}
return NextRight();
}
internal override bool NextRight() {
// Make sure we do not get past the nodeTop if we call NextRight on a just initialized iterator and nodeTop has no children
if ( currentNode == nodeTop ) {
currentNode = null;
return false;
}
XmlNode nextNode = currentNode.NextSibling;
if ( nextNode != null ) {
currentNode = nextNode;
return true;
}
// No next sibling, try the first sibling of from the parent chain
nextNode = currentNode;
while ( nextNode != nodeTop && nextNode.NextSibling == null )
nextNode = nextNode.ParentNode;
if ( nextNode == nodeTop ) {
currentNode = null;
return false;
}
currentNode = nextNode.NextSibling;
Debug.Assert( currentNode != null );
return true;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// [....]
// [....]
//-----------------------------------------------------------------------------
#pragma warning disable 618 // ignore obsolete warning about XmlDataDocument
namespace System.Xml {
using System.Diagnostics;
// Iterates over non-attribute nodes
internal sealed class TreeIterator : BaseTreeIterator {
private XmlNode nodeTop;
private XmlNode currentNode;
internal TreeIterator( XmlNode nodeTop ) : base( ((XmlDataDocument)(nodeTop.OwnerDocument)).Mapper ) {
Debug.Assert( nodeTop != null );
this.nodeTop = nodeTop;
this.currentNode = nodeTop;
}
internal override void Reset() {
currentNode = nodeTop;
}
internal override XmlNode CurrentNode {
get {
return currentNode;
}
}
internal override bool Next() {
XmlNode nextNode;
// Try to move to the first child
nextNode = currentNode.FirstChild;
// No children, try next sibling
if ( nextNode != null ) {
currentNode = nextNode;
return true;
}
return NextRight();
}
internal override bool NextRight() {
// Make sure we do not get past the nodeTop if we call NextRight on a just initialized iterator and nodeTop has no children
if ( currentNode == nodeTop ) {
currentNode = null;
return false;
}
XmlNode nextNode = currentNode.NextSibling;
if ( nextNode != null ) {
currentNode = nextNode;
return true;
}
// No next sibling, try the first sibling of from the parent chain
nextNode = currentNode;
while ( nextNode != nodeTop && nextNode.NextSibling == null )
nextNode = nextNode.ParentNode;
if ( nextNode == nodeTop ) {
currentNode = null;
return false;
}
currentNode = nextNode.NextSibling;
Debug.Assert( currentNode != null );
return true;
}
}
}
// 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
- ClientFormsAuthenticationMembershipProvider.cs
- SQLGuidStorage.cs
- ObjectSet.cs
- SegmentInfo.cs
- ResourceDictionary.cs
- StylesEditorDialog.cs
- DtrList.cs
- HeaderUtility.cs
- ExceptionValidationRule.cs
- WpfXamlLoader.cs
- processwaithandle.cs
- UnknownWrapper.cs
- CommandBindingCollection.cs
- File.cs
- Queue.cs
- ProfileModule.cs
- ComplexLine.cs
- SymmetricAlgorithm.cs
- XamlWriter.cs
- MultiBindingExpression.cs
- exports.cs
- FileUpload.cs
- PropertyGeneratedEventArgs.cs
- EncodingConverter.cs
- ProfileSettings.cs
- Brush.cs
- ModuleBuilderData.cs
- FactoryId.cs
- BlurBitmapEffect.cs
- SHA1.cs
- BitmapDownload.cs
- Error.cs
- DesignerMetadata.cs
- ImportContext.cs
- HttpHeaderCollection.cs
- SmiRequestExecutor.cs
- KeyPullup.cs
- ConfigXmlDocument.cs
- NameObjectCollectionBase.cs
- xamlnodes.cs
- WinFormsComponentEditor.cs
- SubclassTypeValidator.cs
- RecordsAffectedEventArgs.cs
- LinearGradientBrush.cs
- SqlCacheDependencySection.cs
- TextTreeTextBlock.cs
- ExpressionConverter.cs
- DataGridViewEditingControlShowingEventArgs.cs
- ContainerControl.cs
- EntityProxyFactory.cs
- _DigestClient.cs
- HttpAsyncResult.cs
- BaseValidatorDesigner.cs
- ConnectionManagementElement.cs
- FrameworkContentElement.cs
- FontUnit.cs
- ResourceDefaultValueAttribute.cs
- XmlSchemaSimpleTypeUnion.cs
- WebColorConverter.cs
- ConnectionManagementElement.cs
- NullableDoubleMinMaxAggregationOperator.cs
- ResourceReferenceExpressionConverter.cs
- Size.cs
- _TimerThread.cs
- XhtmlBasicTextViewAdapter.cs
- GridView.cs
- InvalidProgramException.cs
- GlyphTypeface.cs
- precedingsibling.cs
- XmlIncludeAttribute.cs
- IDQuery.cs
- ErasingStroke.cs
- httpserverutility.cs
- ScriptModule.cs
- SourceSwitch.cs
- WithStatement.cs
- Model3DCollection.cs
- XmlDocument.cs
- DeferredRunTextReference.cs
- GenericEnumConverter.cs
- HttpProcessUtility.cs
- CommandHelper.cs
- PixelFormat.cs
- BinaryExpression.cs
- TakeQueryOptionExpression.cs
- PhysicalAddress.cs
- FieldAccessException.cs
- RecognizerInfo.cs
- XmlIgnoreAttribute.cs
- ExceptionWrapper.cs
- FormsAuthenticationModule.cs
- EncryptedHeaderXml.cs
- EdmSchemaError.cs
- TagMapInfo.cs
- UniqueSet.cs
- ReadOnlyNameValueCollection.cs
- RtfNavigator.cs
- ReflectionHelper.cs
- TraceContextRecord.cs
- ValuePatternIdentifiers.cs