Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- CategoryGridEntry.cs
- MarkerProperties.cs
- MemoryFailPoint.cs
- StatusBarItemAutomationPeer.cs
- PointLightBase.cs
- CodeDirectiveCollection.cs
- Compress.cs
- Rotation3DAnimationUsingKeyFrames.cs
- BindValidationContext.cs
- _FtpControlStream.cs
- CacheModeConverter.cs
- SqlDataReader.cs
- WS2007HttpBindingElement.cs
- FacetChecker.cs
- ItemsControlAutomationPeer.cs
- StringPropertyBuilder.cs
- SqlVersion.cs
- ISFClipboardData.cs
- Renderer.cs
- Context.cs
- FlowLayoutSettings.cs
- WaitHandle.cs
- SizeAnimationUsingKeyFrames.cs
- FontCollection.cs
- DynamicUpdateCommand.cs
- RequestBringIntoViewEventArgs.cs
- BasicViewGenerator.cs
- PageOutputColor.cs
- AudioStateChangedEventArgs.cs
- TabOrder.cs
- Win32.cs
- DatagridviewDisplayedBandsData.cs
- BamlRecordHelper.cs
- Schema.cs
- PerformanceCounterManager.cs
- ServiceNameCollection.cs
- PriorityQueue.cs
- HttpCookie.cs
- XmlNamedNodeMap.cs
- CompilerResults.cs
- DynamicMethod.cs
- CommentEmitter.cs
- XmlSchemaValidator.cs
- PackageProperties.cs
- EditorPartCollection.cs
- SerTrace.cs
- MasterPageCodeDomTreeGenerator.cs
- ArithmeticException.cs
- ReadOnlyCollection.cs
- LayoutEngine.cs
- RequestCachingSection.cs
- TdsParserSafeHandles.cs
- FacetEnabledSchemaElement.cs
- XmlSchemaAny.cs
- TextTreeFixupNode.cs
- RoleBoolean.cs
- RecordBuilder.cs
- LineBreakRecord.cs
- XmlSchemaAny.cs
- WindowsRebar.cs
- ClientSettingsStore.cs
- DerivedKeySecurityTokenStub.cs
- StatusBar.cs
- followingsibling.cs
- EventManager.cs
- BamlLocalizableResourceKey.cs
- LineVisual.cs
- EDesignUtil.cs
- ParseNumbers.cs
- MiniAssembly.cs
- EntityTypeEmitter.cs
- mediapermission.cs
- TouchEventArgs.cs
- ProgressChangedEventArgs.cs
- PageBreakRecord.cs
- SaveWorkflowAsyncResult.cs
- RecipientInfo.cs
- XmlObjectSerializerWriteContextComplex.cs
- CodeFieldReferenceExpression.cs
- Monitor.cs
- WorkflowWebHostingModule.cs
- Debug.cs
- MemoryMappedFile.cs
- Tablet.cs
- ReachDocumentReferenceSerializerAsync.cs
- TextServicesManager.cs
- formatter.cs
- CodeFieldReferenceExpression.cs
- BooleanToSelectiveScrollingOrientationConverter.cs
- InvokeGenerator.cs
- CatalogPart.cs
- IgnoreDataMemberAttribute.cs
- ConfigurationStrings.cs
- ImpersonationContext.cs
- BasicCellRelation.cs
- MouseOverProperty.cs
- Glyph.cs
- EffectiveValueEntry.cs
- EditCommandColumn.cs
- BackgroundWorker.cs