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
- BaseTreeIterator.cs
- SignatureDescription.cs
- DesignerVerbToolStripMenuItem.cs
- AccessibleObject.cs
- MissingManifestResourceException.cs
- TextBoxBase.cs
- SurrogateChar.cs
- CompilationLock.cs
- DependencyObjectProvider.cs
- peersecurityelement.cs
- Set.cs
- UIElement3DAutomationPeer.cs
- CultureMapper.cs
- EntityRecordInfo.cs
- ConfigDefinitionUpdates.cs
- WebPartConnectionsDisconnectVerb.cs
- ParallelLoopState.cs
- MenuItem.cs
- ScalarOps.cs
- FunctionMappingTranslator.cs
- ServiceManager.cs
- ConfigurationLocationCollection.cs
- RelationshipFixer.cs
- TreeSet.cs
- _HeaderInfo.cs
- WebPartConnection.cs
- UInt64Converter.cs
- BamlLocalizationDictionary.cs
- AuthorizationSection.cs
- SourceFilter.cs
- ThumbAutomationPeer.cs
- TypedElement.cs
- AxisAngleRotation3D.cs
- SortDescriptionCollection.cs
- CloudCollection.cs
- MaskInputRejectedEventArgs.cs
- LowerCaseStringConverter.cs
- DispatcherEventArgs.cs
- ChangeProcessor.cs
- cache.cs
- OleDragDropHandler.cs
- WindowInteractionStateTracker.cs
- NativeMethods.cs
- CodeDOMUtility.cs
- AttributeSetAction.cs
- DataGridPagerStyle.cs
- TaiwanLunisolarCalendar.cs
- PlaceHolder.cs
- TreeNodeStyleCollection.cs
- ContainerVisual.cs
- SimplePropertyEntry.cs
- Pkcs7Signer.cs
- XmlSecureResolver.cs
- ListViewInsertionMark.cs
- TypeDescriptionProviderAttribute.cs
- ObjectParameter.cs
- TemplatedAdorner.cs
- IncrementalCompileAnalyzer.cs
- SoapIncludeAttribute.cs
- DynamicPropertyHolder.cs
- X509Utils.cs
- SQLStringStorage.cs
- graph.cs
- Directory.cs
- ColorTransform.cs
- C14NUtil.cs
- FileChangesMonitor.cs
- ListViewItemEventArgs.cs
- EdmSchemaError.cs
- InputScopeConverter.cs
- OdbcDataReader.cs
- InputLanguageEventArgs.cs
- SelectionUIService.cs
- Point4D.cs
- COM2ICategorizePropertiesHandler.cs
- TouchFrameEventArgs.cs
- TraceFilter.cs
- SQLDecimal.cs
- ValidationPropertyAttribute.cs
- ReaderContextStackData.cs
- ObjectStateManagerMetadata.cs
- NavigationProperty.cs
- DbConnectionPoolCounters.cs
- WindowsFormsDesignerOptionService.cs
- DesignSurfaceServiceContainer.cs
- InternalDispatchObject.cs
- CheckBoxPopupAdapter.cs
- ConnectionPoint.cs
- PkcsUtils.cs
- OperationCanceledException.cs
- TypeToken.cs
- DataRecord.cs
- WSHttpSecurity.cs
- DependencyPropertyConverter.cs
- IssuedTokenClientElement.cs
- TraceFilter.cs
- ObjectRef.cs
- CodeAttachEventStatement.cs
- UDPClient.cs
- CodeNamespaceImport.cs