Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Shared / MS / Internal / GenericEnumerator.cs / 1305600 / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- HtmlContainerControl.cs
- Thread.cs
- HttpProfileBase.cs
- Codec.cs
- FrameworkPropertyMetadata.cs
- User.cs
- DesignParameter.cs
- SqlBulkCopy.cs
- securitycriticaldataClass.cs
- JoinTreeSlot.cs
- XmlSchemaInclude.cs
- WindowsTooltip.cs
- SoundPlayer.cs
- XmlRawWriterWrapper.cs
- GetPageNumberCompletedEventArgs.cs
- DetailsViewDeletedEventArgs.cs
- ScriptReferenceEventArgs.cs
- FrameDimension.cs
- SQLGuid.cs
- RowToFieldTransformer.cs
- SafeReadContext.cs
- ManagementEventArgs.cs
- SqlGenericUtil.cs
- SyndicationPerson.cs
- Tuple.cs
- SponsorHelper.cs
- ThicknessConverter.cs
- Table.cs
- PreservationFileReader.cs
- baseshape.cs
- XamlPointCollectionSerializer.cs
- MetadataWorkspace.cs
- StatusCommandUI.cs
- WebResourceAttribute.cs
- AccessDataSource.cs
- TypeBuilder.cs
- ListenerElementsCollection.cs
- QuaternionAnimationUsingKeyFrames.cs
- Animatable.cs
- FusionWrap.cs
- ClientScriptManager.cs
- ScriptMethodAttribute.cs
- nulltextnavigator.cs
- EncodedStreamFactory.cs
- ReservationCollection.cs
- EditorPartChrome.cs
- TemplateAction.cs
- BoundConstants.cs
- DesignerActionVerbList.cs
- NominalTypeEliminator.cs
- PlaceHolder.cs
- DictionaryEntry.cs
- EndpointDiscoveryBehavior.cs
- SQLBytesStorage.cs
- ColumnHeaderConverter.cs
- EnumValAlphaComparer.cs
- ToolStripSplitButton.cs
- WebContext.cs
- MethodBuilder.cs
- TokenDescriptor.cs
- DynamicValueConverter.cs
- PriorityBindingExpression.cs
- HandoffBehavior.cs
- Vector3DIndependentAnimationStorage.cs
- OutputCacheEntry.cs
- ConfigurationSectionCollection.cs
- NameService.cs
- Run.cs
- SqlProfileProvider.cs
- ControlPersister.cs
- ObjectListItemCollection.cs
- EventlogProvider.cs
- CheckBox.cs
- CultureInfoConverter.cs
- OutOfMemoryException.cs
- WmfPlaceableFileHeader.cs
- RemotingAttributes.cs
- WebBrowserBase.cs
- SqlReferenceCollection.cs
- TrackingRecord.cs
- FontSource.cs
- TextEncodedRawTextWriter.cs
- FilterQueryOptionExpression.cs
- SessionStateContainer.cs
- HwndSourceParameters.cs
- TraceContext.cs
- IdentityNotMappedException.cs
- Not.cs
- UnsafeNativeMethods.cs
- Stacktrace.cs
- TraceProvider.cs
- SmtpReplyReaderFactory.cs
- TemplateControlBuildProvider.cs
- Size.cs
- StringAnimationBase.cs
- ColorConvertedBitmap.cs
- CustomErrorCollection.cs
- NativeCompoundFileAPIs.cs
- XmlDocumentViewSchema.cs
- UpdatePanelControlTrigger.cs