Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / BCL / System / Collections / CompatibleComparer.cs / 1305376 / CompatibleComparer.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== //[....] // using System.Diagnostics.Contracts; namespace System.Collections { [Serializable] internal class CompatibleComparer: IEqualityComparer { IComparer _comparer; #pragma warning disable 618 IHashCodeProvider _hcp; internal CompatibleComparer(IComparer comparer, IHashCodeProvider hashCodeProvider) { _comparer = comparer; _hcp = hashCodeProvider; } #pragma warning restore 618 public int Compare(Object a, Object b) { if (a == b) return 0; if (a == null) return -1; if (b == null) return 1; if (_comparer != null) return _comparer.Compare(a,b); IComparable ia = a as IComparable; if (ia != null) return ia.CompareTo(b); throw new ArgumentException(Environment.GetResourceString("Argument_ImplementIComparable")); } public new bool Equals(Object a, Object b) { return Compare(a, b) == 0; } public int GetHashCode(Object obj) { if( obj == null) { throw new ArgumentNullException("obj"); } Contract.EndContractBlock(); if (_hcp != null) return _hcp.GetHashCode(obj); return obj.GetHashCode(); } // These are helpers for the Hashtable to query the IKeyComparer infrastructure. internal IComparer Comparer { get { return _comparer; } } // These are helpers for the Hashtable to query the IKeyComparer infrastructure. #pragma warning disable 618 internal IHashCodeProvider HashCodeProvider { get { return _hcp; } } #pragma warning restore 618 } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== //[....] // using System.Diagnostics.Contracts; namespace System.Collections { [Serializable] internal class CompatibleComparer: IEqualityComparer { IComparer _comparer; #pragma warning disable 618 IHashCodeProvider _hcp; internal CompatibleComparer(IComparer comparer, IHashCodeProvider hashCodeProvider) { _comparer = comparer; _hcp = hashCodeProvider; } #pragma warning restore 618 public int Compare(Object a, Object b) { if (a == b) return 0; if (a == null) return -1; if (b == null) return 1; if (_comparer != null) return _comparer.Compare(a,b); IComparable ia = a as IComparable; if (ia != null) return ia.CompareTo(b); throw new ArgumentException(Environment.GetResourceString("Argument_ImplementIComparable")); } public new bool Equals(Object a, Object b) { return Compare(a, b) == 0; } public int GetHashCode(Object obj) { if( obj == null) { throw new ArgumentNullException("obj"); } Contract.EndContractBlock(); if (_hcp != null) return _hcp.GetHashCode(obj); return obj.GetHashCode(); } // These are helpers for the Hashtable to query the IKeyComparer infrastructure. internal IComparer Comparer { get { return _comparer; } } // These are helpers for the Hashtable to query the IKeyComparer infrastructure. #pragma warning disable 618 internal IHashCodeProvider HashCodeProvider { get { return _hcp; } } #pragma warning restore 618 } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- StrongName.cs
- BamlRecordWriter.cs
- ScriptMethodAttribute.cs
- VirtualDirectoryMapping.cs
- ObjectListSelectEventArgs.cs
- PropertyDescriptorComparer.cs
- ProcessHost.cs
- BaseDataListPage.cs
- SHA512.cs
- MessageRpc.cs
- ClipboardProcessor.cs
- EmptyStringExpandableObjectConverter.cs
- PropertyGridView.cs
- Cloud.cs
- PersonalizationProviderCollection.cs
- HtmlControl.cs
- EventLog.cs
- ListDependantCardsRequest.cs
- CryptoApi.cs
- UrlRoutingHandler.cs
- NavigationProperty.cs
- Facet.cs
- DefaultEventAttribute.cs
- ComPersistableTypeElementCollection.cs
- EntityTemplateFactory.cs
- AccessorTable.cs
- SerializerWriterEventHandlers.cs
- ToolStripManager.cs
- Rectangle.cs
- EmptyControlCollection.cs
- bidPrivateBase.cs
- StringComparer.cs
- LockedHandleGlyph.cs
- OSFeature.cs
- DelayedRegex.cs
- ListViewAutomationPeer.cs
- ScriptingProfileServiceSection.cs
- DataGridCellItemAutomationPeer.cs
- IisHelper.cs
- SubpageParaClient.cs
- ManagementPath.cs
- InputScopeManager.cs
- PersonalizationAdministration.cs
- RemoveStoryboard.cs
- EventDescriptor.cs
- SizeValueSerializer.cs
- ProxyElement.cs
- TextEffectCollection.cs
- Visitor.cs
- EntityModelSchemaGenerator.cs
- NonVisualControlAttribute.cs
- invalidudtexception.cs
- MailWebEventProvider.cs
- RangeContentEnumerator.cs
- EdmProviderManifest.cs
- MasterPageBuildProvider.cs
- SliderAutomationPeer.cs
- DataGridViewCellStyleChangedEventArgs.cs
- EntityReference.cs
- PersonalizationDictionary.cs
- ListItemsCollectionEditor.cs
- ListenerUnsafeNativeMethods.cs
- ImplicitInputBrush.cs
- CapabilitiesPattern.cs
- StorageComplexTypeMapping.cs
- MemoryFailPoint.cs
- StringPropertyBuilder.cs
- OleServicesContext.cs
- WindowHideOrCloseTracker.cs
- DataErrorValidationRule.cs
- PolicyChain.cs
- MDIClient.cs
- StatusBarPanel.cs
- ReadOnlyAttribute.cs
- StandardRuntimeEnumValidator.cs
- OperatorExpressions.cs
- _DomainName.cs
- HandlerFactoryWrapper.cs
- NetworkCredential.cs
- TreeNodeEventArgs.cs
- AutomationPropertyInfo.cs
- CodeNamespace.cs
- MSAAWinEventWrap.cs
- NonVisualControlAttribute.cs
- BindingList.cs
- COM2ExtendedTypeConverter.cs
- DataGridTablesFactory.cs
- XmlDictionaryString.cs
- DefaultDiscoveryServiceExtension.cs
- ScrollableControl.cs
- HttpContext.cs
- TemplatedWizardStep.cs
- precedingquery.cs
- DbMetaDataFactory.cs
- SchemaTableColumn.cs
- SettingsPropertyCollection.cs
- InfiniteIntConverter.cs
- StateMachineDesignerPaint.cs
- DataGridViewAddColumnDialog.cs
- SharedUtils.cs