Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ProcessModuleCollection.cs
- DataTableNewRowEvent.cs
- WsdlBuildProvider.cs
- CalendarDateRange.cs
- ImageListStreamer.cs
- WebPartRestoreVerb.cs
- EntityDesignerUtils.cs
- CacheOutputQuery.cs
- FileDialogCustomPlacesCollection.cs
- SByteConverter.cs
- DependencyPropertyValueSerializer.cs
- ReliabilityContractAttribute.cs
- BuildProviderAppliesToAttribute.cs
- HttpApplicationFactory.cs
- Int64AnimationBase.cs
- ConnectionManagementElementCollection.cs
- MarginCollapsingState.cs
- RepeatButton.cs
- RetrieveVirtualItemEventArgs.cs
- Line.cs
- CompilationUtil.cs
- VolatileResourceManager.cs
- EventProxy.cs
- DBParameter.cs
- BindableTemplateBuilder.cs
- PolicyChain.cs
- UnconditionalPolicy.cs
- CodePageEncoding.cs
- SqlBuilder.cs
- BindingExpression.cs
- ReadOnlyCollection.cs
- AssemblyBuilder.cs
- EventArgs.cs
- DrawingState.cs
- AttributeQuery.cs
- CmsInterop.cs
- TypeHelpers.cs
- SQLMoneyStorage.cs
- ToolStripOverflowButton.cs
- sqlinternaltransaction.cs
- WebResourceAttribute.cs
- FormatControl.cs
- TextTreeRootTextBlock.cs
- XPathNodeInfoAtom.cs
- XmlObjectSerializerReadContextComplexJson.cs
- WindowsFormsHelpers.cs
- GridPattern.cs
- UInt64Converter.cs
- RepeaterItem.cs
- XamlDesignerSerializationManager.cs
- StorageConditionPropertyMapping.cs
- QilTernary.cs
- PartBasedPackageProperties.cs
- QueryableDataSourceEditData.cs
- LinqDataSourceHelper.cs
- TextViewSelectionProcessor.cs
- returneventsaver.cs
- Slider.cs
- GrammarBuilderDictation.cs
- RecognizedAudio.cs
- RoleGroup.cs
- PersistenceTypeAttribute.cs
- ToolStripGripRenderEventArgs.cs
- TCEAdapterGenerator.cs
- TransactionProtocolConverter.cs
- BitmapEffect.cs
- CardSpaceSelector.cs
- safemediahandle.cs
- RequestCacheEntry.cs
- SqlAggregateChecker.cs
- RuleSet.cs
- Frame.cs
- HttpVersion.cs
- FileDialog_Vista.cs
- XPathExpr.cs
- StopStoryboard.cs
- TextTreeObjectNode.cs
- GridViewPageEventArgs.cs
- Size3D.cs
- TaskForm.cs
- XmlSerializerOperationGenerator.cs
- DiscoveryClientProtocol.cs
- PackageDigitalSignatureManager.cs
- InvalidCommandTreeException.cs
- SessionStateModule.cs
- UseAttributeSetsAction.cs
- FontCacheUtil.cs
- WindowsGraphicsWrapper.cs
- IndentTextWriter.cs
- FixedSOMPageElement.cs
- FontFamilyConverter.cs
- EntityReference.cs
- Utils.cs
- ALinqExpressionVisitor.cs
- TriggerCollection.cs
- ConnectionsZoneDesigner.cs
- ProtocolsConfiguration.cs
- IDReferencePropertyAttribute.cs
- HtmlTable.cs
- SecurityState.cs