Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Xml / System / Xml / XPath / Internal / DescendantOverDescendantQuery.cs / 1 / DescendantOverDescendantQuery.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// [....]
//-----------------------------------------------------------------------------
namespace MS.Internal.Xml.XPath {
using System;
using System.Xml;
using System.Xml.XPath;
using System.Diagnostics;
// DescendantOverDescendantQuery: for each input it looks for the topmost descendents that matches to ns:name
// This is posible when query which has this query as its input (child query) is descendent as well.
// Work of this query doesn't depend on DOD of its input.
// It doesn't garate DOD of the output even when input is DOD.
internal sealed class DescendantOverDescendantQuery : DescendantBaseQuery {
private int level = 0;
public DescendantOverDescendantQuery(Query qyParent, bool matchSelf, string name, string prefix, XPathNodeType typeTest, bool abbrAxis) :
base(qyParent, name, prefix, typeTest, matchSelf, abbrAxis) {}
private DescendantOverDescendantQuery(DescendantOverDescendantQuery other) : base(other) {
this.level = other.level;
}
public override void Reset() {
level = 0;
base.Reset();
}
public override XPathNavigator Advance() {
while (true) {
if (level == 0) {
currentNode = qyInput.Advance();
position = 0;
if (currentNode == null) {
return null;
}
if (matchSelf && matches(currentNode)) {
position = 1;
return currentNode;
}
currentNode = currentNode.Clone();
if (! MoveToFirstChild()) {
continue;
}
} else {
if (!MoveUpUntillNext()) {
continue;
}
}
do {
if (matches(currentNode)) {
position++;
return currentNode;
}
} while (MoveToFirstChild());
}
}
private bool MoveToFirstChild() {
if (currentNode.MoveToFirstChild()) {
level++;
return true;
}
return false;
}
private bool MoveUpUntillNext() { // move up untill we can move next
while (! currentNode.MoveToNext()) {
-- level;
if (level == 0) {
return false;
}
bool result = currentNode.MoveToParent();
Debug.Assert(result, "Algorithm error, We always should be able to move up if level > 0");
}
return true;
}
public override XPathNodeIterator Clone() { return new DescendantOverDescendantQuery(this); }
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ACE.cs
- TemplateControl.cs
- NullExtension.cs
- CommittableTransaction.cs
- AuthenticateEventArgs.cs
- PositiveTimeSpanValidatorAttribute.cs
- StringValidator.cs
- ObjectConverter.cs
- UIElement3D.cs
- Switch.cs
- CorruptingExceptionCommon.cs
- WebPartZoneDesigner.cs
- ColumnBinding.cs
- DataGridViewHitTestInfo.cs
- DataControlCommands.cs
- SqlCrossApplyToCrossJoin.cs
- ListInitExpression.cs
- GridViewAutomationPeer.cs
- Soap12ProtocolReflector.cs
- DefaultAsyncDataDispatcher.cs
- UnitySerializationHolder.cs
- MethodResolver.cs
- AutomationPropertyInfo.cs
- DelegateHelpers.Generated.cs
- MultitargetUtil.cs
- EventRouteFactory.cs
- MergeFailedEvent.cs
- XmlSchemaNotation.cs
- UnsafeNativeMethods.cs
- COSERVERINFO.cs
- PointValueSerializer.cs
- NumberSubstitution.cs
- C14NUtil.cs
- Html32TextWriter.cs
- DbConnectionClosed.cs
- DrawingContext.cs
- Transform.cs
- ListViewGroupConverter.cs
- EventlogProvider.cs
- TextSerializer.cs
- HealthMonitoringSection.cs
- CurrencyWrapper.cs
- Win32.cs
- HtmlTitle.cs
- __Filters.cs
- DatasetMethodGenerator.cs
- PeerNameRegistration.cs
- TailPinnedEventArgs.cs
- Pair.cs
- DataGridDesigner.cs
- StateBag.cs
- TextDocumentView.cs
- ManipulationDelta.cs
- VectorConverter.cs
- HotSpot.cs
- ISCIIEncoding.cs
- SchemaNames.cs
- BitmapEffect.cs
- SelfSignedCertificate.cs
- AutoCompleteStringCollection.cs
- StringKeyFrameCollection.cs
- StandardTransformFactory.cs
- SafeEventLogReadHandle.cs
- Storyboard.cs
- HelpFileFileNameEditor.cs
- Profiler.cs
- ConnectorEditor.cs
- CustomErrorCollection.cs
- AbstractExpressions.cs
- UInt32Storage.cs
- Emitter.cs
- AssemblyBuilder.cs
- PersianCalendar.cs
- FilteredAttributeCollection.cs
- ZipIOZip64EndOfCentralDirectoryBlock.cs
- EntitySetBase.cs
- TrustLevelCollection.cs
- Bits.cs
- HttpRequestMessageProperty.cs
- HttpCachePolicyWrapper.cs
- WriteFileContext.cs
- RuleInfoComparer.cs
- InstanceLockTracking.cs
- DataRelation.cs
- Context.cs
- EncryptedReference.cs
- HWStack.cs
- Activity.cs
- RecognizedWordUnit.cs
- Query.cs
- DynamicMethod.cs
- TextServicesManager.cs
- AxImporter.cs
- DataSpaceManager.cs
- MimeWriter.cs
- FrameworkContentElement.cs
- HtmlImage.cs
- XmlUrlResolver.cs
- TrustLevelCollection.cs
- DropShadowEffect.cs