Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Xml / System / Xml / XPath / Internal / XPathSelectionIterator.cs / 1305376 / XPathSelectionIterator.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;
using System.Globalization;
// We need this wrapper object to:
// 1. Calculate position
// 2. Protect internal query.Current from user who may call MoveNext().
internal class XPathSelectionIterator : ResetableIterator {
private XPathNavigator nav;
private Query query;
private int position;
internal XPathSelectionIterator(XPathNavigator nav, Query query) {
this.nav = nav.Clone();
this.query = query;
}
protected XPathSelectionIterator(XPathSelectionIterator it) {
this.nav = it.nav.Clone();
this.query = (Query) it.query.Clone();
this.position = it.position;
}
public override void Reset() {
this.query.Reset();
}
public override bool MoveNext() {
XPathNavigator n = query.Advance();
if( n != null ) {
position++;
if (!nav.MoveTo(n)) {
nav = n.Clone();
}
return true;
}
return false;
}
public override int Count { get { return query.Count; } }
public override XPathNavigator Current { get { return nav; } }
public override int CurrentPosition { get { return position; } }
public override XPathNodeIterator Clone() { return new XPathSelectionIterator(this); }
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// [....]
//-----------------------------------------------------------------------------
namespace MS.Internal.Xml.XPath {
using System;
using System.Xml;
using System.Xml.XPath;
using System.Diagnostics;
using System.Globalization;
// We need this wrapper object to:
// 1. Calculate position
// 2. Protect internal query.Current from user who may call MoveNext().
internal class XPathSelectionIterator : ResetableIterator {
private XPathNavigator nav;
private Query query;
private int position;
internal XPathSelectionIterator(XPathNavigator nav, Query query) {
this.nav = nav.Clone();
this.query = query;
}
protected XPathSelectionIterator(XPathSelectionIterator it) {
this.nav = it.nav.Clone();
this.query = (Query) it.query.Clone();
this.position = it.position;
}
public override void Reset() {
this.query.Reset();
}
public override bool MoveNext() {
XPathNavigator n = query.Advance();
if( n != null ) {
position++;
if (!nav.MoveTo(n)) {
nav = n.Clone();
}
return true;
}
return false;
}
public override int Count { get { return query.Count; } }
public override XPathNavigator Current { get { return nav; } }
public override int CurrentPosition { get { return position; } }
public override XPathNodeIterator Clone() { return new XPathSelectionIterator(this); }
}
}
// 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
- WindowsGraphicsCacheManager.cs
- OrderByExpression.cs
- SmiConnection.cs
- Animatable.cs
- DragEvent.cs
- FormsAuthenticationTicket.cs
- WebPartTransformerCollection.cs
- AxHost.cs
- DataGridViewRowCancelEventArgs.cs
- MatrixValueSerializer.cs
- UserControl.cs
- StylusTip.cs
- FontWeightConverter.cs
- DigestTraceRecordHelper.cs
- ObjectViewEntityCollectionData.cs
- TableRowGroupCollection.cs
- Types.cs
- LogWriteRestartAreaAsyncResult.cs
- ParameterDataSourceExpression.cs
- StartFileNameEditor.cs
- odbcmetadatacolumnnames.cs
- TdsParserStaticMethods.cs
- Facet.cs
- UnknownBitmapEncoder.cs
- ProfileManager.cs
- GridViewHeaderRowPresenter.cs
- FixedBufferAttribute.cs
- SerializationException.cs
- WindowsListViewGroup.cs
- ConditionChanges.cs
- DefaultExpression.cs
- DataPagerField.cs
- SessionPageStatePersister.cs
- Trace.cs
- TreeBuilderBamlTranslator.cs
- MissingManifestResourceException.cs
- RegionInfo.cs
- EditorPartCollection.cs
- XmlCharCheckingWriter.cs
- ClientBase.cs
- FormsAuthenticationConfiguration.cs
- CommonProperties.cs
- MenuCommands.cs
- DataTemplateSelector.cs
- PartialCachingControl.cs
- FileDialogPermission.cs
- SplitterPanel.cs
- ClientProxyGenerator.cs
- CapabilitiesState.cs
- SqlDataSourceCommandEventArgs.cs
- CodeNamespace.cs
- TextBoxLine.cs
- ScrollBar.cs
- OledbConnectionStringbuilder.cs
- PrivilegeNotHeldException.cs
- COM2ExtendedBrowsingHandler.cs
- RuleAction.cs
- LicFileLicenseProvider.cs
- AppModelKnownContentFactory.cs
- ScrollableControl.cs
- DeclarativeCatalogPart.cs
- SafeFileHandle.cs
- ParseChildrenAsPropertiesAttribute.cs
- FixedSOMGroup.cs
- NotFiniteNumberException.cs
- XhtmlMobileTextWriter.cs
- BitmapSourceSafeMILHandle.cs
- keycontainerpermission.cs
- NavigationWindowAutomationPeer.cs
- WebServiceHandlerFactory.cs
- Merger.cs
- ExternalFile.cs
- SeekStoryboard.cs
- MaskInputRejectedEventArgs.cs
- RowBinding.cs
- KeyGestureValueSerializer.cs
- FormsAuthenticationTicket.cs
- RadialGradientBrush.cs
- TreeView.cs
- Calendar.cs
- PrinterSettings.cs
- GridSplitterAutomationPeer.cs
- MSAANativeProvider.cs
- SHA1CryptoServiceProvider.cs
- AtomEntry.cs
- ConnectionStringSettingsCollection.cs
- ProviderCollection.cs
- DashStyle.cs
- ClientData.cs
- TextAdaptor.cs
- InternalSafeNativeMethods.cs
- HtmlTableRow.cs
- ReflectionPermission.cs
- ToolStripTextBox.cs
- DataExpression.cs
- LinqDataSourceHelper.cs
- Nullable.cs
- StateManagedCollection.cs
- RawAppCommandInputReport.cs
- AppSettingsSection.cs