Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / XmlUtils / System / Xml / Xsl / Runtime / SiblingIterators.cs / 1 / SiblingIterators.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// [....]
//-----------------------------------------------------------------------------
using System;
using System.Xml;
using System.Xml.XPath;
using System.Xml.Schema;
using System.Diagnostics;
using System.Collections;
using System.ComponentModel;
namespace System.Xml.Xsl.Runtime {
///
/// Iterate over all following-sibling content nodes.
///
[EditorBrowsable(EditorBrowsableState.Never)]
public struct FollowingSiblingIterator {
private XmlNavigatorFilter filter;
private XPathNavigator navCurrent;
///
/// Initialize the FollowingSiblingIterator.
///
public void Create(XPathNavigator context, XmlNavigatorFilter filter) {
this.navCurrent = XmlQueryRuntime.SyncToNavigator(this.navCurrent, context);
this.filter = filter;
}
///
/// Position the iterator on the next following-sibling node. Return true if such a node exists and
/// set Current property. Otherwise, return false (Current property is undefined).
///
public bool MoveNext() {
return this.filter.MoveToFollowingSibling(this.navCurrent);
}
///
/// Return the current result navigator. This is only defined after MoveNext() has returned true.
///
public XPathNavigator Current {
get { return this.navCurrent; }
}
}
///
/// Iterate over child following-sibling nodes. This is a simple variation on the ContentMergeIterator, so use containment
/// to reuse its code (can't use inheritance with structures).
///
[EditorBrowsable(EditorBrowsableState.Never)]
public struct FollowingSiblingMergeIterator {
private ContentMergeIterator wrapped;
///
/// Initialize the FollowingSiblingMergeIterator.
///
public void Create(XmlNavigatorFilter filter) {
this.wrapped.Create(filter);
}
///
/// Position this iterator to the next content or sibling node. Return IteratorResult.NoMoreNodes if there are
/// no more content or sibling nodes. Return IteratorResult.NeedInputNode if the next input node needs to be
/// fetched first. Return IteratorResult.HaveCurrent if the Current property is set to the next node in the
/// iteration.
///
public IteratorResult MoveNext(XPathNavigator navigator) {
return this.wrapped.MoveNext(navigator, false);
}
///
/// Return the current result navigator. This is only defined after MoveNext() has returned IteratorResult.HaveCurrent.
///
public XPathNavigator Current {
get { return this.wrapped.Current; }
}
}
///
/// Iterate over all preceding nodes according to XPath preceding axis rules, returning nodes in reverse
/// document order.
///
[EditorBrowsable(EditorBrowsableState.Never)]
public struct PrecedingSiblingIterator {
private XmlNavigatorFilter filter;
private XPathNavigator navCurrent;
///
/// Initialize the PrecedingSiblingIterator.
///
public void Create(XPathNavigator context, XmlNavigatorFilter filter) {
this.navCurrent = XmlQueryRuntime.SyncToNavigator(this.navCurrent, context);
this.filter = filter;
}
///
/// Return true if the Current property is set to the next Preceding node in reverse document order.
///
public bool MoveNext() {
return this.filter.MoveToPreviousSibling(this.navCurrent);
}
///
/// Return the current result navigator. This is only defined after MoveNext() has returned true.
///
public XPathNavigator Current {
get { return this.navCurrent; }
}
}
///
/// Iterate over all preceding-sibling content nodes in document order.
///
[EditorBrowsable(EditorBrowsableState.Never)]
public struct PrecedingSiblingDocOrderIterator {
private XmlNavigatorFilter filter;
private XPathNavigator navCurrent, navEnd;
private bool needFirst, useCompPos;
///
/// Initialize the PrecedingSiblingDocOrderIterator.
///
public void Create(XPathNavigator context, XmlNavigatorFilter filter) {
this.filter = filter;
this.navCurrent = XmlQueryRuntime.SyncToNavigator(this.navCurrent, context);
this.navEnd = XmlQueryRuntime.SyncToNavigator(this.navEnd, context);
this.needFirst = true;
// If the context node will be filtered out, then use ComparePosition to
// determine when the context node has been passed by. Otherwise, IsSamePosition
// is sufficient to determine when the context node has been reached.
this.useCompPos = this.filter.IsFiltered(context);
}
///
/// Position the iterator on the next preceding-sibling node. Return true if such a node exists and
/// set Current property. Otherwise, return false (Current property is undefined).
///
public bool MoveNext() {
if (this.needFirst) {
// Get first matching preceding-sibling node
if (!this.navCurrent.MoveToParent())
return false;
if (!this.filter.MoveToContent(this.navCurrent))
return false;
this.needFirst = false;
}
else {
// Get next matching preceding-sibling node
if (!this.filter.MoveToFollowingSibling(this.navCurrent))
return false;
}
// Accept matching sibling only if it precedes navEnd in document order
if (this.useCompPos)
return (this.navCurrent.ComparePosition(this.navEnd) == XmlNodeOrder.Before);
if (this.navCurrent.IsSamePosition(this.navEnd)) {
// Found the original context node, so iteration is complete. If MoveNext
// is called again, use ComparePosition so that false will continue to be
// returned.
this.useCompPos = true;
return false;
}
return true;
}
///
/// Return the current result navigator. This is only defined after MoveNext() has returned true.
///
public XPathNavigator Current {
get { return this.navCurrent; }
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// [....]
//-----------------------------------------------------------------------------
using System;
using System.Xml;
using System.Xml.XPath;
using System.Xml.Schema;
using System.Diagnostics;
using System.Collections;
using System.ComponentModel;
namespace System.Xml.Xsl.Runtime {
///
/// Iterate over all following-sibling content nodes.
///
[EditorBrowsable(EditorBrowsableState.Never)]
public struct FollowingSiblingIterator {
private XmlNavigatorFilter filter;
private XPathNavigator navCurrent;
///
/// Initialize the FollowingSiblingIterator.
///
public void Create(XPathNavigator context, XmlNavigatorFilter filter) {
this.navCurrent = XmlQueryRuntime.SyncToNavigator(this.navCurrent, context);
this.filter = filter;
}
///
/// Position the iterator on the next following-sibling node. Return true if such a node exists and
/// set Current property. Otherwise, return false (Current property is undefined).
///
public bool MoveNext() {
return this.filter.MoveToFollowingSibling(this.navCurrent);
}
///
/// Return the current result navigator. This is only defined after MoveNext() has returned true.
///
public XPathNavigator Current {
get { return this.navCurrent; }
}
}
///
/// Iterate over child following-sibling nodes. This is a simple variation on the ContentMergeIterator, so use containment
/// to reuse its code (can't use inheritance with structures).
///
[EditorBrowsable(EditorBrowsableState.Never)]
public struct FollowingSiblingMergeIterator {
private ContentMergeIterator wrapped;
///
/// Initialize the FollowingSiblingMergeIterator.
///
public void Create(XmlNavigatorFilter filter) {
this.wrapped.Create(filter);
}
///
/// Position this iterator to the next content or sibling node. Return IteratorResult.NoMoreNodes if there are
/// no more content or sibling nodes. Return IteratorResult.NeedInputNode if the next input node needs to be
/// fetched first. Return IteratorResult.HaveCurrent if the Current property is set to the next node in the
/// iteration.
///
public IteratorResult MoveNext(XPathNavigator navigator) {
return this.wrapped.MoveNext(navigator, false);
}
///
/// Return the current result navigator. This is only defined after MoveNext() has returned IteratorResult.HaveCurrent.
///
public XPathNavigator Current {
get { return this.wrapped.Current; }
}
}
///
/// Iterate over all preceding nodes according to XPath preceding axis rules, returning nodes in reverse
/// document order.
///
[EditorBrowsable(EditorBrowsableState.Never)]
public struct PrecedingSiblingIterator {
private XmlNavigatorFilter filter;
private XPathNavigator navCurrent;
///
/// Initialize the PrecedingSiblingIterator.
///
public void Create(XPathNavigator context, XmlNavigatorFilter filter) {
this.navCurrent = XmlQueryRuntime.SyncToNavigator(this.navCurrent, context);
this.filter = filter;
}
///
/// Return true if the Current property is set to the next Preceding node in reverse document order.
///
public bool MoveNext() {
return this.filter.MoveToPreviousSibling(this.navCurrent);
}
///
/// Return the current result navigator. This is only defined after MoveNext() has returned true.
///
public XPathNavigator Current {
get { return this.navCurrent; }
}
}
///
/// Iterate over all preceding-sibling content nodes in document order.
///
[EditorBrowsable(EditorBrowsableState.Never)]
public struct PrecedingSiblingDocOrderIterator {
private XmlNavigatorFilter filter;
private XPathNavigator navCurrent, navEnd;
private bool needFirst, useCompPos;
///
/// Initialize the PrecedingSiblingDocOrderIterator.
///
public void Create(XPathNavigator context, XmlNavigatorFilter filter) {
this.filter = filter;
this.navCurrent = XmlQueryRuntime.SyncToNavigator(this.navCurrent, context);
this.navEnd = XmlQueryRuntime.SyncToNavigator(this.navEnd, context);
this.needFirst = true;
// If the context node will be filtered out, then use ComparePosition to
// determine when the context node has been passed by. Otherwise, IsSamePosition
// is sufficient to determine when the context node has been reached.
this.useCompPos = this.filter.IsFiltered(context);
}
///
/// Position the iterator on the next preceding-sibling node. Return true if such a node exists and
/// set Current property. Otherwise, return false (Current property is undefined).
///
public bool MoveNext() {
if (this.needFirst) {
// Get first matching preceding-sibling node
if (!this.navCurrent.MoveToParent())
return false;
if (!this.filter.MoveToContent(this.navCurrent))
return false;
this.needFirst = false;
}
else {
// Get next matching preceding-sibling node
if (!this.filter.MoveToFollowingSibling(this.navCurrent))
return false;
}
// Accept matching sibling only if it precedes navEnd in document order
if (this.useCompPos)
return (this.navCurrent.ComparePosition(this.navEnd) == XmlNodeOrder.Before);
if (this.navCurrent.IsSamePosition(this.navEnd)) {
// Found the original context node, so iteration is complete. If MoveNext
// is called again, use ComparePosition so that false will continue to be
// returned.
this.useCompPos = true;
return false;
}
return true;
}
///
/// Return the current result navigator. This is only defined after MoveNext() has returned true.
///
public XPathNavigator Current {
get { return this.navCurrent; }
}
}
}
// 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
- HttpProfileBase.cs
- IPEndPoint.cs
- initElementDictionary.cs
- DataGridDefaultColumnWidthTypeConverter.cs
- XmlNodeReader.cs
- Parser.cs
- TextTreeRootTextBlock.cs
- SqlBuilder.cs
- ReadOnlyDictionary.cs
- PerspectiveCamera.cs
- DataGridViewButtonColumn.cs
- StyleCollection.cs
- WhitespaceRuleLookup.cs
- TemplateControlCodeDomTreeGenerator.cs
- LocalTransaction.cs
- ProcessModelInfo.cs
- DesignerSerializationVisibilityAttribute.cs
- PasswordPropertyTextAttribute.cs
- XmlLangPropertyAttribute.cs
- Version.cs
- TransformedBitmap.cs
- DesignerDataSchemaClass.cs
- xml.cs
- Int16Storage.cs
- PropertyInfoSet.cs
- SystemColors.cs
- AssociationSetEnd.cs
- BinarySecretSecurityToken.cs
- UriWriter.cs
- PromptBuilder.cs
- _SafeNetHandles.cs
- PowerEase.cs
- TextDecorationCollection.cs
- CorePropertiesFilter.cs
- HtmlInputHidden.cs
- AutomationPeer.cs
- VectorCollectionConverter.cs
- WmlTextBoxAdapter.cs
- CodeTypeMemberCollection.cs
- Predicate.cs
- NavigationProperty.cs
- PowerModeChangedEventArgs.cs
- RectAnimationClockResource.cs
- InputScopeAttribute.cs
- Mappings.cs
- PagedDataSource.cs
- Messages.cs
- SplineQuaternionKeyFrame.cs
- TextEditorMouse.cs
- TextBox.cs
- FilteredSchemaElementLookUpTable.cs
- ExceptionRoutedEventArgs.cs
- XmlByteStreamReader.cs
- HeaderedContentControl.cs
- ElementHostAutomationPeer.cs
- EditorResources.cs
- LambdaCompiler.Address.cs
- RequestCacheValidator.cs
- EventRoute.cs
- errorpatternmatcher.cs
- PackageProperties.cs
- LZCodec.cs
- DocumentPageHost.cs
- LineGeometry.cs
- TypeUnloadedException.cs
- DefaultSection.cs
- DockPanel.cs
- SoundPlayer.cs
- OutputScope.cs
- SynchronizationLockException.cs
- RuleInfoComparer.cs
- DefaultBinder.cs
- EntityContainerRelationshipSetEnd.cs
- BaseParser.cs
- DiagnosticsElement.cs
- DesignerAdRotatorAdapter.cs
- ViewCellSlot.cs
- NullableIntAverageAggregationOperator.cs
- DomNameTable.cs
- XmlSchemaSimpleContent.cs
- SortDescriptionCollection.cs
- ServiceOperationWrapper.cs
- QuadraticBezierSegment.cs
- RenderDataDrawingContext.cs
- RealizationDrawingContextWalker.cs
- DependencyPropertyConverter.cs
- ScriptRegistrationManager.cs
- XPathAncestorQuery.cs
- EventSinkActivity.cs
- AutoCompleteStringCollection.cs
- BookmarkCallbackWrapper.cs
- SR.Designer.cs
- LoginView.cs
- MonthChangedEventArgs.cs
- ProcessThread.cs
- XhtmlBasicTextViewAdapter.cs
- OdbcEnvironment.cs
- DataGridHyperlinkColumn.cs
- GridEntryCollection.cs
- MouseButton.cs