Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Shared / MS / Internal / WeakReferenceEnumerator.cs / 1 / WeakReferenceEnumerator.cs
using System; using System.Collections; using System.Windows; #if WINDOWS_BASE using MS.Internal.WindowsBase; #elif PRESENTATION_CORE using MS.Internal.PresentationCore; #elif PRESENTATIONFRAMEWORK using MS.Internal.PresentationFramework; #elif DRT using MS.Internal.Drt; #else #error Attempt to use FriendAccessAllowedAttribute from an unknown assembly. using MS.Internal.YourAssemblyName; #endif // Disable pragma warnings to enable PREsharp pragmas #pragma warning disable 1634, 1691 namespace MS.Internal { ////// This allows callers to "foreach" through a WeakReferenceList. /// Each weakreference is checked for liveness and "current" /// actually returns a strong reference to the current element. /// ////// Due to the way enumerators function, this enumerator often /// holds a cached strong reference to the "Current" element. /// This should not be a problem unless the caller stops enumerating /// before the end of the list AND holds the enumerator alive forever. /// [FriendAccessAllowed] internal struct WeakReferenceListEnumerator : IEnumerator { public WeakReferenceListEnumerator( ArrayList List) { _i = 0; _List = List; _StrongReference = null; } object IEnumerator.Current { get{ return Current; } } public object Current { get { if( null == _StrongReference ) { #pragma warning suppress 6503 throw new System.InvalidOperationException(SR.Get(SRID.Enumerator_VerifyContext)); } return _StrongReference; } } public bool MoveNext() { object obj=null; while( _i < _List.Count ) { WeakReference weakRef = (WeakReference) _List[ _i++ ]; obj = weakRef.Target; if(null != obj) break; } _StrongReference = obj; return (null != obj); } public void Reset() { _i = 0; _StrongReference = null; } int _i; ArrayList _List; object _StrongReference; } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. using System; using System.Collections; using System.Windows; #if WINDOWS_BASE using MS.Internal.WindowsBase; #elif PRESENTATION_CORE using MS.Internal.PresentationCore; #elif PRESENTATIONFRAMEWORK using MS.Internal.PresentationFramework; #elif DRT using MS.Internal.Drt; #else #error Attempt to use FriendAccessAllowedAttribute from an unknown assembly. using MS.Internal.YourAssemblyName; #endif // Disable pragma warnings to enable PREsharp pragmas #pragma warning disable 1634, 1691 namespace MS.Internal { ////// This allows callers to "foreach" through a WeakReferenceList. /// Each weakreference is checked for liveness and "current" /// actually returns a strong reference to the current element. /// ////// Due to the way enumerators function, this enumerator often /// holds a cached strong reference to the "Current" element. /// This should not be a problem unless the caller stops enumerating /// before the end of the list AND holds the enumerator alive forever. /// [FriendAccessAllowed] internal struct WeakReferenceListEnumerator : IEnumerator { public WeakReferenceListEnumerator( ArrayList List) { _i = 0; _List = List; _StrongReference = null; } object IEnumerator.Current { get{ return Current; } } public object Current { get { if( null == _StrongReference ) { #pragma warning suppress 6503 throw new System.InvalidOperationException(SR.Get(SRID.Enumerator_VerifyContext)); } return _StrongReference; } } public bool MoveNext() { object obj=null; while( _i < _List.Count ) { WeakReference weakRef = (WeakReference) _List[ _i++ ]; obj = weakRef.Target; if(null != obj) break; } _StrongReference = obj; return (null != obj); } public void Reset() { _i = 0; _StrongReference = null; } int _i; ArrayList _List; object _StrongReference; } } // 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
- LiteralControl.cs
- DefaultValueConverter.cs
- ExpressionPrefixAttribute.cs
- DrawingContext.cs
- LineServicesCallbacks.cs
- ClientBase.cs
- XmlSchemaObjectCollection.cs
- SystemInfo.cs
- TreeViewDesigner.cs
- PageTheme.cs
- MethodBuilderInstantiation.cs
- AttributedMetaModel.cs
- XmlAttributeCache.cs
- WindowsTooltip.cs
- TableRow.cs
- SqlCacheDependencyDatabaseCollection.cs
- JournalNavigationScope.cs
- SettingsSection.cs
- IndexingContentUnit.cs
- ProcessManager.cs
- XamlNamespaceHelper.cs
- DataGridTableCollection.cs
- AnnotationStore.cs
- MimeTypePropertyAttribute.cs
- TreeNodeStyle.cs
- ConversionContext.cs
- Rotation3DAnimationBase.cs
- MbpInfo.cs
- SafeNativeMethods.cs
- HttpException.cs
- PropertyDescriptor.cs
- _BufferOffsetSize.cs
- CLRBindingWorker.cs
- ResolveRequestResponseAsyncResult.cs
- WindowsTokenRoleProvider.cs
- DataGridViewToolTip.cs
- AssociationSetEnd.cs
- HtmlProps.cs
- WebPartTracker.cs
- WindowsListViewItem.cs
- RSAPKCS1KeyExchangeFormatter.cs
- RowsCopiedEventArgs.cs
- TreeView.cs
- FilterableAttribute.cs
- EndpointIdentityConverter.cs
- BamlResourceDeserializer.cs
- SingleObjectCollection.cs
- LineSegment.cs
- OuterGlowBitmapEffect.cs
- ExpandCollapseProviderWrapper.cs
- ListViewEditEventArgs.cs
- SamlAttribute.cs
- LinqDataSourceInsertEventArgs.cs
- PinnedBufferMemoryStream.cs
- PlaceHolder.cs
- DbProviderManifest.cs
- safex509handles.cs
- Command.cs
- ObjectSecurity.cs
- PagerSettings.cs
- safemediahandle.cs
- SerializationEventsCache.cs
- AnonymousIdentificationSection.cs
- ToolStripItem.cs
- InfoCardRSAPKCS1SignatureFormatter.cs
- SortAction.cs
- ToolBarPanel.cs
- PriorityItem.cs
- NativeMethods.cs
- CodeCommentStatementCollection.cs
- SqlTypesSchemaImporter.cs
- KeyGestureConverter.cs
- SmtpException.cs
- TableLayout.cs
- TextEffectCollection.cs
- EntityTypeBase.cs
- Exceptions.cs
- NavigationProgressEventArgs.cs
- ContactManager.cs
- SettingsPropertyNotFoundException.cs
- ViewLoader.cs
- BoundColumn.cs
- PaperSource.cs
- BitmapEffectvisualstate.cs
- TriggerBase.cs
- ActiveXHelper.cs
- FontFamilyConverter.cs
- RtfControls.cs
- UpdatableGenericsFeature.cs
- RuntimeHandles.cs
- Point3D.cs
- Overlapped.cs
- SoapFormatter.cs
- CompressStream.cs
- SemaphoreFullException.cs
- EdmProperty.cs
- RegisteredDisposeScript.cs
- SystemFonts.cs
- RefreshPropertiesAttribute.cs
- InstallerTypeAttribute.cs