Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Shared / MS / Internal / GenericEnumerator.cs / 1 / GenericEnumerator.cs
//------------------------------------------------------------------------------ // Microsoft Avalon // Copyright (c) Microsoft Corporation, 2001 // // File: GenericEnumerator.cs //----------------------------------------------------------------------------- using System; using System.Collections; using System.Diagnostics; using System.Windows; using MS.Utility; #if PRESENTATION_CORE using SR=MS.Internal.PresentationCore.SR; using SRID=MS.Internal.PresentationCore.SRID; #else using SR=System.Windows.SR; using SRID=System.Windows.SRID; #endif namespace MS.Internal { ////// GenericEnumerator /// internal class GenericEnumerator : IEnumerator { #region Delegates internal delegate int GetGenerationIDDelegate(); #endregion #region Constructors private GenericEnumerator() { } internal GenericEnumerator(IList array, GetGenerationIDDelegate getGenerationID) { _array = array; _count = _array.Count; _position = -1; _getGenerationID = getGenerationID; _originalGenerationID = _getGenerationID(); } #endregion #region Private private void VerifyCurrent() { if ( (-1 == _position) || (_position >= _count)) { throw new InvalidOperationException(SR.Get(SRID.Enumerator_VerifyContext)); } } #endregion #region IEnumerator ////// Returns the object at the current location of the key times list. /// Use the strongly typed version instead. /// object IEnumerator.Current { get { VerifyCurrent(); return _current; } } ////// Move to the next value in the key times list /// ///true if succeeded, false if at the end of the list public bool MoveNext() { if (_getGenerationID() != _originalGenerationID) { throw new InvalidOperationException(SR.Get(SRID.Enumerator_CollectionChanged)); } _position++; if (_position >= _count) { _position = _count; return false; } else { Debug.Assert(_position >= 0); _current = _array[_position]; return true; } } ////// Move to the position before the first value in the list. /// public void Reset() { if (_getGenerationID() != _originalGenerationID) { throw new InvalidOperationException(SR.Get(SRID.Enumerator_CollectionChanged)); } else { _position = -1; } } #endregion #region Data private IList _array; private object _current; private int _count; private int _position; private int _originalGenerationID; private GetGenerationIDDelegate _getGenerationID; #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //------------------------------------------------------------------------------ // Microsoft Avalon // Copyright (c) Microsoft Corporation, 2001 // // File: GenericEnumerator.cs //----------------------------------------------------------------------------- using System; using System.Collections; using System.Diagnostics; using System.Windows; using MS.Utility; #if PRESENTATION_CORE using SR=MS.Internal.PresentationCore.SR; using SRID=MS.Internal.PresentationCore.SRID; #else using SR=System.Windows.SR; using SRID=System.Windows.SRID; #endif namespace MS.Internal { ////// GenericEnumerator /// internal class GenericEnumerator : IEnumerator { #region Delegates internal delegate int GetGenerationIDDelegate(); #endregion #region Constructors private GenericEnumerator() { } internal GenericEnumerator(IList array, GetGenerationIDDelegate getGenerationID) { _array = array; _count = _array.Count; _position = -1; _getGenerationID = getGenerationID; _originalGenerationID = _getGenerationID(); } #endregion #region Private private void VerifyCurrent() { if ( (-1 == _position) || (_position >= _count)) { throw new InvalidOperationException(SR.Get(SRID.Enumerator_VerifyContext)); } } #endregion #region IEnumerator ////// Returns the object at the current location of the key times list. /// Use the strongly typed version instead. /// object IEnumerator.Current { get { VerifyCurrent(); return _current; } } ////// Move to the next value in the key times list /// ///true if succeeded, false if at the end of the list public bool MoveNext() { if (_getGenerationID() != _originalGenerationID) { throw new InvalidOperationException(SR.Get(SRID.Enumerator_CollectionChanged)); } _position++; if (_position >= _count) { _position = _count; return false; } else { Debug.Assert(_position >= 0); _current = _array[_position]; return true; } } ////// Move to the position before the first value in the list. /// public void Reset() { if (_getGenerationID() != _originalGenerationID) { throw new InvalidOperationException(SR.Get(SRID.Enumerator_CollectionChanged)); } else { _position = -1; } } #endregion #region Data private IList _array; private object _current; private int _count; private int _position; private int _originalGenerationID; private GetGenerationIDDelegate _getGenerationID; #endregion } } // 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
- MatrixValueSerializer.cs
- SQLGuidStorage.cs
- BitmapEffectGeneralTransform.cs
- Calendar.cs
- NotImplementedException.cs
- WindowsFormsSectionHandler.cs
- FileInfo.cs
- DataGridViewCellValidatingEventArgs.cs
- BaseDataListDesigner.cs
- ResourceDescriptionAttribute.cs
- SingleQueryOperator.cs
- DbDataAdapter.cs
- DeclarativeCatalogPartDesigner.cs
- BamlTreeMap.cs
- XamlHostingConfiguration.cs
- AttributeQuery.cs
- FrameAutomationPeer.cs
- StickyNote.cs
- WebConfigManager.cs
- BaseResourcesBuildProvider.cs
- COM2ColorConverter.cs
- FontCollection.cs
- SelectionChangedEventArgs.cs
- InheritanceAttribute.cs
- HtmlTable.cs
- DataBoundControlAdapter.cs
- SqlConnectionStringBuilder.cs
- PermissionListSet.cs
- VersionedStreamOwner.cs
- MethodImplAttribute.cs
- ContentHostHelper.cs
- Stopwatch.cs
- InputManager.cs
- ProcessingInstructionAction.cs
- Misc.cs
- CustomWebEventKey.cs
- CodeIdentifier.cs
- ProfileSettingsCollection.cs
- DBCSCodePageEncoding.cs
- SyntaxCheck.cs
- ComplexType.cs
- CacheDependency.cs
- CodeActivity.cs
- FileDialog_Vista_Interop.cs
- AbstractSvcMapFileLoader.cs
- JapaneseCalendar.cs
- ListItemParagraph.cs
- SoapHttpTransportImporter.cs
- BufferedResponseStream.cs
- HttpContextWrapper.cs
- TemplateBamlTreeBuilder.cs
- LinkButton.cs
- SqlCacheDependency.cs
- SiteMapNode.cs
- ObjectStorage.cs
- ClientConfigPaths.cs
- GroupBoxAutomationPeer.cs
- SqlAggregateChecker.cs
- DynamicResourceExtension.cs
- XmlValidatingReader.cs
- LocalBuilder.cs
- DetailsViewRow.cs
- XmlAttributeOverrides.cs
- UIPermission.cs
- ListControl.cs
- UniformGrid.cs
- DateTimeSerializationSection.cs
- PaintEvent.cs
- ResourceExpressionBuilder.cs
- ApplicationId.cs
- SafeRightsManagementEnvironmentHandle.cs
- AutomationPattern.cs
- Accessors.cs
- UnhandledExceptionEventArgs.cs
- UrlAuthFailedErrorFormatter.cs
- AppSettingsExpressionBuilder.cs
- FloaterBaseParagraph.cs
- UnmanagedMemoryStreamWrapper.cs
- ToolBar.cs
- UnsafeNativeMethods.cs
- SelectionItemProviderWrapper.cs
- ContentOperations.cs
- ObjectItemCachedAssemblyLoader.cs
- ErrorTableItemStyle.cs
- _NegoState.cs
- updateconfighost.cs
- IndentedWriter.cs
- VisualTarget.cs
- X509SecurityTokenParameters.cs
- XmlElementAttribute.cs
- TileBrush.cs
- EntityCommandExecutionException.cs
- AssemblyCollection.cs
- smtppermission.cs
- ComplexPropertyEntry.cs
- Error.cs
- TileBrush.cs
- DataSetUtil.cs
- WindowsAltTab.cs
- DataGridLinkButton.cs