Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Base / MS / Internal / WeakReferenceKey.cs / 1305600 / WeakReferenceKey.cs
//---------------------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // Description: // This file defines a class that holds a weak reference to an object. It preserves the hashcode // of the object and is intended to be used as a key in hashtables or dictionaries. // //------------------------------------------------------------------------------------- using System; using MS.Internal; namespace MS.Internal.Utility { ////// Helper class that allows using a weak reference to an item as a key in a hash table. /// internal class WeakReferenceKey{ public WeakReferenceKey(T item) { Invariant.Assert(item != null); _item = new WeakReference(item); _hashCode = item.GetHashCode(); } public T Item { get { return (T)_item.Target; } } public override bool Equals(object o) { if (o == this) return true; WeakReferenceKey key = o as WeakReferenceKey ; if (key != null) { T item = this.Item; if (item == null) return false; // a stale key matches nothing (except itself) return this._hashCode == key._hashCode && Object.Equals(item, key.Item); } return false; } public override int GetHashCode() { return _hashCode; } private WeakReference _item; private int _hashCode; } } // 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
- ControlCachePolicy.cs
- AuthenticationSection.cs
- DisposableCollectionWrapper.cs
- ThicknessKeyFrameCollection.cs
- ViewStateModeByIdAttribute.cs
- BitSet.cs
- DirectionalLight.cs
- ReadOnlyDataSource.cs
- SqlWebEventProvider.cs
- OleDbConnection.cs
- MSG.cs
- DispatcherExceptionFilterEventArgs.cs
- RegisteredDisposeScript.cs
- Query.cs
- ImageCodecInfoPrivate.cs
- GetPageCompletedEventArgs.cs
- ItemsPresenter.cs
- Module.cs
- MailSettingsSection.cs
- TemplateField.cs
- TemplatePagerField.cs
- CodePrimitiveExpression.cs
- TrustManagerPromptUI.cs
- UnsafeNativeMethods.cs
- List.cs
- TreeViewItem.cs
- _SecureChannel.cs
- CompilationRelaxations.cs
- SizeConverter.cs
- TransformerInfo.cs
- TextBoxAutoCompleteSourceConverter.cs
- WindowsSecurityTokenAuthenticator.cs
- HostingPreferredMapPath.cs
- PropertyMappingExceptionEventArgs.cs
- Vector3DAnimationUsingKeyFrames.cs
- HandledEventArgs.cs
- AssemblyResourceLoader.cs
- QueryableFilterUserControl.cs
- GcHandle.cs
- DataGridPageChangedEventArgs.cs
- PropertyPath.cs
- compensatingcollection.cs
- PriorityRange.cs
- MailWriter.cs
- XmlSecureResolver.cs
- ListViewHitTestInfo.cs
- ValidationResult.cs
- TableChangeProcessor.cs
- NumberSubstitution.cs
- mda.cs
- WorkflowInstanceExtensionManager.cs
- WeakReadOnlyCollection.cs
- BlurBitmapEffect.cs
- CqlIdentifiers.cs
- ChangeInterceptorAttribute.cs
- FixedDocumentSequencePaginator.cs
- AsyncDataRequest.cs
- SafeThemeHandle.cs
- CompareInfo.cs
- SymbolDocumentGenerator.cs
- PropertyGroupDescription.cs
- MaskedTextBoxTextEditor.cs
- DataGridRowHeader.cs
- ConfigurationConverterBase.cs
- ImageDrawing.cs
- DataGridViewIntLinkedList.cs
- CustomValidator.cs
- ProfilePropertyMetadata.cs
- RuleRef.cs
- RuntimeConfigLKG.cs
- DataControlReference.cs
- BitmapEffectOutputConnector.cs
- PropertyGroupDescription.cs
- BuilderElements.cs
- HierarchicalDataTemplate.cs
- DataReaderContainer.cs
- DockEditor.cs
- UIElement.cs
- xsdvalidator.cs
- BaseCollection.cs
- Sql8ConformanceChecker.cs
- XmlNodeComparer.cs
- DataReaderContainer.cs
- SQLChars.cs
- DrawingGroupDrawingContext.cs
- Update.cs
- ConstantSlot.cs
- HttpCapabilitiesSectionHandler.cs
- XmlSerializer.cs
- RequestQueue.cs
- SourceSwitch.cs
- DesignerVerb.cs
- WindowsListView.cs
- ItemAutomationPeer.cs
- TableProviderWrapper.cs
- DbConnectionInternal.cs
- Boolean.cs
- IntPtr.cs
- BasePropertyDescriptor.cs
- BamlBinaryReader.cs