Code:
/ 4.0 / 4.0 / 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. //------------------------------------------------------------------------------ // 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
- FieldNameLookup.cs
- figurelength.cs
- TryCatchDesigner.xaml.cs
- DrawItemEvent.cs
- IdentityValidationException.cs
- AxHost.cs
- UIAgentMonitor.cs
- HtmlShim.cs
- QilStrConcatenator.cs
- ComplexType.cs
- DynamicActivityXamlReader.cs
- GregorianCalendarHelper.cs
- MarshalByRefObject.cs
- InteropAutomationProvider.cs
- ObjectStateEntryDbDataRecord.cs
- wgx_render.cs
- AppModelKnownContentFactory.cs
- GridEntry.cs
- ButtonAutomationPeer.cs
- CultureInfo.cs
- CommonRemoteMemoryBlock.cs
- SourceFileInfo.cs
- _ServiceNameStore.cs
- PopupControlService.cs
- LassoHelper.cs
- WebServiceErrorEvent.cs
- SplineQuaternionKeyFrame.cs
- WindowsSlider.cs
- HitTestResult.cs
- CompoundFileIOPermission.cs
- BooleanAnimationBase.cs
- AttributeSetAction.cs
- RTLAwareMessageBox.cs
- UInt16.cs
- bidPrivateBase.cs
- WebInvokeAttribute.cs
- SqlPersistenceWorkflowInstanceDescription.cs
- Focus.cs
- TextRangeAdaptor.cs
- CompoundFileStreamReference.cs
- EdmProperty.cs
- ModuleConfigurationInfo.cs
- QuaternionRotation3D.cs
- MessageDesigner.cs
- SystemParameters.cs
- ContentTextAutomationPeer.cs
- TextCollapsingProperties.cs
- TdsParserSessionPool.cs
- WorkflowMarkupSerializer.cs
- PageCatalogPart.cs
- SecureStringHasher.cs
- AdministrationHelpers.cs
- ToolStripContentPanelRenderEventArgs.cs
- StickyNoteAnnotations.cs
- DnsElement.cs
- FixedFindEngine.cs
- ClientConfigPaths.cs
- StringReader.cs
- DefinitionUpdate.cs
- LastQueryOperator.cs
- ToolStripItemTextRenderEventArgs.cs
- WebPartExportVerb.cs
- UITypeEditor.cs
- FunctionUpdateCommand.cs
- HotSpot.cs
- ScriptReferenceBase.cs
- EDesignUtil.cs
- PageAsyncTask.cs
- mansign.cs
- EdmSchemaError.cs
- ADMembershipUser.cs
- EditorAttribute.cs
- GcHandle.cs
- WebPartDescription.cs
- CompressionTracing.cs
- Brush.cs
- EntityDesignerDataSourceView.cs
- ResourceDescriptionAttribute.cs
- FormsIdentity.cs
- counter.cs
- NumberSubstitution.cs
- ColumnHeader.cs
- SessionStateModule.cs
- GPPOINTF.cs
- SourceFileBuildProvider.cs
- WorkItem.cs
- ValidationErrorEventArgs.cs
- XmlSchemaInfo.cs
- AutoGeneratedField.cs
- MiniMapControl.xaml.cs
- Util.cs
- ChineseLunisolarCalendar.cs
- LightweightCodeGenerator.cs
- X500Name.cs
- NamedPipeTransportSecurity.cs
- DataContractSerializer.cs
- ModelEditingScope.cs
- Fonts.cs
- HashCodeCombiner.cs
- Point3DValueSerializer.cs