Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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
- ServiceBuildProvider.cs
- LoadRetryConstantStrategy.cs
- GridViewUpdatedEventArgs.cs
- TemplateControlBuildProvider.cs
- OlePropertyStructs.cs
- BackgroundFormatInfo.cs
- SqlRetyper.cs
- NativeObjectSecurity.cs
- HostAdapter.cs
- HelpKeywordAttribute.cs
- AnnotationHelper.cs
- Binding.cs
- CompensatableTransactionScopeActivity.cs
- sortedlist.cs
- OSFeature.cs
- StylusButtonCollection.cs
- ColorDialog.cs
- MenuItem.cs
- StatusBarItem.cs
- CatalogPartChrome.cs
- ContainerActivationHelper.cs
- TraceSection.cs
- ContractMethodParameterInfo.cs
- SiteMapNodeItemEventArgs.cs
- PreloadedPackages.cs
- ThemeableAttribute.cs
- ProgressBarBrushConverter.cs
- InkSerializer.cs
- ToolStripDropDownClosedEventArgs.cs
- ByteStream.cs
- PageContentCollection.cs
- ScrollProviderWrapper.cs
- ProgressPage.cs
- MailAddressParser.cs
- CodeAccessPermission.cs
- Vector3DConverter.cs
- TreeIterator.cs
- NavigateUrlConverter.cs
- KeyValueConfigurationCollection.cs
- ZipIOFileItemStream.cs
- TextContainerHelper.cs
- BrowserCapabilitiesCodeGenerator.cs
- TableLayoutStyle.cs
- FileDialog_Vista.cs
- HijriCalendar.cs
- XmlNodeChangedEventArgs.cs
- TextTreeRootNode.cs
- TimersDescriptionAttribute.cs
- EntitySetBaseCollection.cs
- AtomPub10ServiceDocumentFormatter.cs
- UserValidatedEventArgs.cs
- SplineKeyFrames.cs
- DbCommandDefinition.cs
- VisualStyleInformation.cs
- ReaderContextStackData.cs
- EncodingInfo.cs
- InfocardClientCredentials.cs
- DistributedTransactionPermission.cs
- HitTestFilterBehavior.cs
- EdmFunction.cs
- NetworkInformationPermission.cs
- Geometry.cs
- ApplicationServicesHostFactory.cs
- CompressedStack.cs
- MappingModelBuildProvider.cs
- StylusDownEventArgs.cs
- Rect3DConverter.cs
- Pointer.cs
- BamlBinaryReader.cs
- HttpResponseInternalWrapper.cs
- PostBackTrigger.cs
- BamlRecordHelper.cs
- _SslState.cs
- WorkflowInstanceTerminatedRecord.cs
- BlobPersonalizationState.cs
- RsaKeyIdentifierClause.cs
- ReliableMessagingVersion.cs
- SaveFileDialog.cs
- TabControlAutomationPeer.cs
- PropertyContainer.cs
- CompressionTransform.cs
- WarningException.cs
- CodeTypeParameterCollection.cs
- PropertyGridCommands.cs
- ResourceExpression.cs
- CompilerGlobalScopeAttribute.cs
- WsdlImporter.cs
- SafeHandle.cs
- QilPatternFactory.cs
- FontUnit.cs
- BitmapEffectDrawingContextState.cs
- NativeMethods.cs
- HttpRuntime.cs
- DeclarativeCatalogPart.cs
- XhtmlConformanceSection.cs
- TcpSocketManager.cs
- SharedDp.cs
- DiagnosticTraceSource.cs
- CapabilitiesAssignment.cs
- KeyProperty.cs