Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- AlphabetConverter.cs
- TextFormatterImp.cs
- OrthographicCamera.cs
- TraceFilter.cs
- NavigateEvent.cs
- RotateTransform3D.cs
- DBDataPermissionAttribute.cs
- thaishape.cs
- XmlReturnReader.cs
- TileBrush.cs
- TraceContext.cs
- AddInAdapter.cs
- WorkflowInstanceUnhandledExceptionRecord.cs
- NamespaceExpr.cs
- OutputCacheProviderCollection.cs
- BitStack.cs
- ActivityCollectionMarkupSerializer.cs
- SchemaNamespaceManager.cs
- SocketElement.cs
- HScrollProperties.cs
- ErrorStyle.cs
- SecondaryIndexList.cs
- SAPICategories.cs
- DbConnectionHelper.cs
- ResourceAssociationType.cs
- QueueProcessor.cs
- FieldNameLookup.cs
- BitmapCache.cs
- ModifyActivitiesPropertyDescriptor.cs
- WebAdminConfigurationHelper.cs
- RegistrationServices.cs
- ValidationPropertyAttribute.cs
- XmlSerializerVersionAttribute.cs
- UrlPropertyAttribute.cs
- ColorAnimation.cs
- sqlinternaltransaction.cs
- DataSourceXmlAttributeAttribute.cs
- EmptyStringExpandableObjectConverter.cs
- BaseDataListPage.cs
- CompletedAsyncResult.cs
- ApplicationServicesHostFactory.cs
- Identity.cs
- HttpMethodAttribute.cs
- EventLogHandle.cs
- TextBoxRenderer.cs
- AvTraceFormat.cs
- PreDigestedSignedInfo.cs
- _ShellExpression.cs
- ToolStripMenuItem.cs
- UnicodeEncoding.cs
- RuleSettingsCollection.cs
- EventDriven.cs
- EntityDataSourceDesigner.cs
- InputManager.cs
- Literal.cs
- TraceContextRecord.cs
- DynamicDocumentPaginator.cs
- OleDbInfoMessageEvent.cs
- CheckBoxAutomationPeer.cs
- FontFaceLayoutInfo.cs
- EdmComplexPropertyAttribute.cs
- MaskedTextBox.cs
- RenderData.cs
- DependencyPropertyHelper.cs
- SafeNativeMethods.cs
- TcpConnectionPoolSettings.cs
- RegexFCD.cs
- webproxy.cs
- ToolStripDropTargetManager.cs
- HtmlToClrEventProxy.cs
- Int16KeyFrameCollection.cs
- PointCollection.cs
- ChannelDispatcherBase.cs
- Container.cs
- DataRowChangeEvent.cs
- SrgsDocument.cs
- ClientFormsIdentity.cs
- TabPanel.cs
- QuestionEventArgs.cs
- ZoneMembershipCondition.cs
- StyleTypedPropertyAttribute.cs
- RowParagraph.cs
- ScrollChrome.cs
- TextSelectionProcessor.cs
- XPathNavigatorKeyComparer.cs
- ImageKeyConverter.cs
- ElementHostAutomationPeer.cs
- DesignTimeSiteMapProvider.cs
- EpmSyndicationContentSerializer.cs
- ConnectionProviderAttribute.cs
- BufferModeSettings.cs
- JournalEntryListConverter.cs
- LexicalChunk.cs
- NewArrayExpression.cs
- Win32.cs
- MobilePage.cs
- UnitySerializationHolder.cs
- DbUpdateCommandTree.cs
- PasswordRecovery.cs
- SqlNotificationEventArgs.cs