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
- PagedDataSource.cs
- Mapping.cs
- HttpRuntimeSection.cs
- TreeWalker.cs
- SqlUDTStorage.cs
- ReflectionPermission.cs
- UserControlCodeDomTreeGenerator.cs
- UiaCoreTypesApi.cs
- CommandEventArgs.cs
- SoapTypeAttribute.cs
- DependencyPropertyChangedEventArgs.cs
- RecordsAffectedEventArgs.cs
- BoolExpr.cs
- ObjectPersistData.cs
- Group.cs
- ScriptResourceHandler.cs
- WebPartMenu.cs
- XmlObjectSerializer.cs
- SamlAttribute.cs
- TrackPointCollection.cs
- DomNameTable.cs
- ComponentCodeDomSerializer.cs
- LinkClickEvent.cs
- ScrollableControl.cs
- TextSearch.cs
- Psha1DerivedKeyGenerator.cs
- CompiledXpathExpr.cs
- ObjectCloneHelper.cs
- Axis.cs
- TagPrefixAttribute.cs
- DiscardableAttribute.cs
- ToolStripPanelRenderEventArgs.cs
- DataGridAddNewRow.cs
- Parameter.cs
- ObjectDataSourceMethodEventArgs.cs
- SqlRewriteScalarSubqueries.cs
- HttpProfileGroupBase.cs
- ToolStripSettings.cs
- _SslState.cs
- KeyValueConfigurationCollection.cs
- WorkflowIdleElement.cs
- GetWinFXPath.cs
- XmlAnyElementAttributes.cs
- DebugView.cs
- AdornerHitTestResult.cs
- SqlConnectionPoolProviderInfo.cs
- OdbcCommand.cs
- MailMessageEventArgs.cs
- TypeElementCollection.cs
- RealizationDrawingContextWalker.cs
- GlobalDataBindingHandler.cs
- RsaSecurityKey.cs
- WindowsFormsSectionHandler.cs
- WebPartHelpVerb.cs
- WithStatement.cs
- XDRSchema.cs
- ImageBrush.cs
- InternalCache.cs
- SystemColorTracker.cs
- UxThemeWrapper.cs
- ExpressionReplacer.cs
- TextRangeSerialization.cs
- SplitterPanel.cs
- VisualTreeUtils.cs
- XmlAtomicValue.cs
- CustomPopupPlacement.cs
- HttpAsyncResult.cs
- DrawItemEvent.cs
- SqlError.cs
- CompiledQueryCacheEntry.cs
- ResolveInfo.cs
- IndexOutOfRangeException.cs
- Enumerable.cs
- AvTrace.cs
- SafeFileMappingHandle.cs
- TextHidden.cs
- Help.cs
- RowVisual.cs
- EntityCollection.cs
- Point3DAnimationBase.cs
- AppDomainResourcePerfCounters.cs
- Ref.cs
- RC2CryptoServiceProvider.cs
- LicenseException.cs
- InitializingNewItemEventArgs.cs
- dtdvalidator.cs
- XhtmlTextWriter.cs
- AutomationPatternInfo.cs
- WebDescriptionAttribute.cs
- RadioButtonList.cs
- DelayedRegex.cs
- TreeWalkHelper.cs
- StoreContentChangedEventArgs.cs
- DataGridViewToolTip.cs
- DelimitedListTraceListener.cs
- Drawing.cs
- Run.cs
- Util.cs
- ProfileModule.cs
- WebServiceHost.cs