Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / clr / src / BCL / System / Collections / CompatibleComparer.cs / 1 / CompatibleComparer.cs
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");
}
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.
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");
}
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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ArrayWithOffset.cs
- ActivityWithResultWrapper.cs
- _SslSessionsCache.cs
- KeyedCollection.cs
- TextTreeTextBlock.cs
- FormClosingEvent.cs
- SimpleMailWebEventProvider.cs
- Bitmap.cs
- ApplicationInfo.cs
- _ContextAwareResult.cs
- HostingPreferredMapPath.cs
- RtfFormatStack.cs
- CultureInfoConverter.cs
- RoleService.cs
- OlePropertyStructs.cs
- SortableBindingList.cs
- WebServiceReceive.cs
- WindowsToolbarAsMenu.cs
- HandlerBase.cs
- LinkClickEvent.cs
- BitmapCodecInfoInternal.cs
- ParserContext.cs
- DrawListViewSubItemEventArgs.cs
- FilteredDataSetHelper.cs
- MsmqIntegrationProcessProtocolHandler.cs
- ChannelSinkStacks.cs
- HtmlInputImage.cs
- WorkflowOperationBehavior.cs
- BooleanSwitch.cs
- ConsoleCancelEventArgs.cs
- CodeTypeMember.cs
- XmlNamedNodeMap.cs
- ConcurrentBag.cs
- SoapSchemaMember.cs
- FileDetails.cs
- SimpleMailWebEventProvider.cs
- RoutedUICommand.cs
- HorizontalAlignConverter.cs
- ErrorFormatter.cs
- XmlAttributeCollection.cs
- ChtmlTextWriter.cs
- VScrollBar.cs
- _Connection.cs
- DbConnectionHelper.cs
- MetadataException.cs
- DependencySource.cs
- GCHandleCookieTable.cs
- DeploymentSection.cs
- DbModificationClause.cs
- ObjectAnimationBase.cs
- MdImport.cs
- FacetDescription.cs
- DataFormats.cs
- DecimalStorage.cs
- EntityProviderServices.cs
- VectorAnimationBase.cs
- EnumerableCollectionView.cs
- Color.cs
- StructureChangedEventArgs.cs
- TypeDescriptionProviderAttribute.cs
- ListItemConverter.cs
- MultilineStringEditor.cs
- ContentElement.cs
- DataServiceQueryException.cs
- TransformDescriptor.cs
- ReferencedType.cs
- SizeF.cs
- TargetFrameworkUtil.cs
- GenericTypeParameterBuilder.cs
- IdnElement.cs
- TextRunProperties.cs
- VisualBrush.cs
- EntityTransaction.cs
- DbProviderFactory.cs
- QilDataSource.cs
- JsonStringDataContract.cs
- SqlDeflator.cs
- NativeMethods.cs
- AttachmentService.cs
- ConfigurationFileMap.cs
- TextCharacters.cs
- AnonymousIdentificationModule.cs
- FixedStringLookup.cs
- MarkupExtensionSerializer.cs
- SqlClientFactory.cs
- UnescapedXmlDiagnosticData.cs
- PlainXmlDeserializer.cs
- DesignerPerfEventProvider.cs
- XPathSingletonIterator.cs
- XmlNodeReader.cs
- _SecureChannel.cs
- BitmapFrame.cs
- SQLDecimal.cs
- MDIClient.cs
- MenuItem.cs
- CompiledWorkflowDefinitionContext.cs
- LinqDataSourceSelectEventArgs.cs
- ToolStripOverflowButton.cs
- SystemEvents.cs
- Console.cs