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
- DateTimeFormat.cs
- SchemaElementLookUpTable.cs
- HttpListenerRequestTraceRecord.cs
- TemplateComponentConnector.cs
- AuthenticationException.cs
- EncodingDataItem.cs
- DocumentPage.cs
- Rights.cs
- MemberPath.cs
- XmlBinaryReader.cs
- WebConvert.cs
- columnmapfactory.cs
- RadioButton.cs
- PageThemeCodeDomTreeGenerator.cs
- ToolStripArrowRenderEventArgs.cs
- GrammarBuilderWildcard.cs
- SqlPersonalizationProvider.cs
- MTConfigUtil.cs
- DynamicILGenerator.cs
- Highlights.cs
- UserPersonalizationStateInfo.cs
- AssemblyResolver.cs
- RenderingEventArgs.cs
- Publisher.cs
- ObjectStateEntryOriginalDbUpdatableDataRecord.cs
- WorkflowApplicationException.cs
- TreeView.cs
- CollectionDataContract.cs
- TextEvent.cs
- EventWaitHandleSecurity.cs
- TraceSection.cs
- XmlSchemaValidationException.cs
- ConnectionManagementElement.cs
- DynamicControl.cs
- SqlParameterCollection.cs
- Page.cs
- HttpHandler.cs
- Binding.cs
- DataGridViewHitTestInfo.cs
- SettingsProviderCollection.cs
- WsatServiceAddress.cs
- RuntimeResourceSet.cs
- SelectionRange.cs
- ColorConvertedBitmap.cs
- UpdatePanelTriggerCollection.cs
- KeysConverter.cs
- SQLDecimal.cs
- ByteStreamMessageUtility.cs
- ToggleButton.cs
- MainMenu.cs
- StylusPlugInCollection.cs
- ToolStrip.cs
- Int32CollectionValueSerializer.cs
- Emitter.cs
- ZipIOLocalFileHeader.cs
- AuthenticationModuleElementCollection.cs
- ScriptMethodAttribute.cs
- LoginView.cs
- ProjectedSlot.cs
- RowUpdatedEventArgs.cs
- MsmqOutputMessage.cs
- XmlConvert.cs
- Application.cs
- Number.cs
- MobileContainerDesigner.cs
- DesignerActionItemCollection.cs
- IndexerNameAttribute.cs
- _TLSstream.cs
- SystemIPAddressInformation.cs
- SqlDataSourceCustomCommandEditor.cs
- ShapingEngine.cs
- BoundsDrawingContextWalker.cs
- BitmapMetadataEnumerator.cs
- InvalidOleVariantTypeException.cs
- InternalBase.cs
- CancellationTokenSource.cs
- BulletedList.cs
- TypeUtils.cs
- XMLUtil.cs
- HtmlElementEventArgs.cs
- DataGridViewTopRowAccessibleObject.cs
- ZipIOCentralDirectoryBlock.cs
- NavigationWindow.cs
- RadioButtonBaseAdapter.cs
- ScriptReferenceEventArgs.cs
- ReadOnlyHierarchicalDataSource.cs
- UnsafeNativeMethods.cs
- FeatureSupport.cs
- XmlNodeChangedEventArgs.cs
- Rect3DValueSerializer.cs
- TabItemAutomationPeer.cs
- SourceFilter.cs
- HashAlgorithm.cs
- BatchWriter.cs
- ChtmlLinkAdapter.cs
- DataGridRowDetailsEventArgs.cs
- RegionIterator.cs
- DataTemplateSelector.cs
- TextAutomationPeer.cs
- GifBitmapEncoder.cs