Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / 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
}
}
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- OperationCanceledException.cs
- MachineKeyConverter.cs
- SQLMoney.cs
- Authorization.cs
- ServiceMetadataPublishingElement.cs
- AssemblyAttributes.cs
- PointAnimationClockResource.cs
- XmlLanguageConverter.cs
- SupportsEventValidationAttribute.cs
- OleDbDataReader.cs
- HtmlElementCollection.cs
- CreateUserWizardDesigner.cs
- OracleTransaction.cs
- Point3DAnimation.cs
- EntityContainer.cs
- DrawingContext.cs
- TypeDelegator.cs
- DetailsViewDeletedEventArgs.cs
- MailAddressCollection.cs
- IntegerValidatorAttribute.cs
- Int32CAMarshaler.cs
- NativeMethodsCLR.cs
- AdobeCFFWrapper.cs
- Model3D.cs
- ContextMenu.cs
- CodeSnippetExpression.cs
- Stack.cs
- GenerateScriptTypeAttribute.cs
- MissingFieldException.cs
- NameValueConfigurationCollection.cs
- RightsManagementInformation.cs
- PropertyTabChangedEvent.cs
- WmlControlAdapter.cs
- DescendantBaseQuery.cs
- ValueSerializer.cs
- TableCell.cs
- KeyedHashAlgorithm.cs
- TreeViewItemAutomationPeer.cs
- MediaScriptCommandRoutedEventArgs.cs
- WebPartManager.cs
- DragEventArgs.cs
- QuotedPrintableStream.cs
- EdmComplexTypeAttribute.cs
- BitmapEffectState.cs
- DescendentsWalkerBase.cs
- WindowClosedEventArgs.cs
- CodeMethodReturnStatement.cs
- ComplexTypeEmitter.cs
- CreateRefExpr.cs
- RuntimeCompatibilityAttribute.cs
- TheQuery.cs
- TemplateApplicationHelper.cs
- DataContractSerializerElement.cs
- SafeHandle.cs
- ByteRangeDownloader.cs
- TextElementEnumerator.cs
- BoolLiteral.cs
- AutoGeneratedField.cs
- SqlUtil.cs
- StringCollection.cs
- ParagraphResult.cs
- MsmqChannelFactoryBase.cs
- OutputWindow.cs
- ImmComposition.cs
- SerializableAttribute.cs
- ByteStorage.cs
- Flattener.cs
- XmlProcessingInstruction.cs
- VerifyHashRequest.cs
- sqlnorm.cs
- MetadataUtilsSmi.cs
- SubMenuStyleCollection.cs
- DateTimeOffsetConverter.cs
- SystemTcpStatistics.cs
- GradientStopCollection.cs
- CollectionType.cs
- SQLResource.cs
- WindowsRichEditRange.cs
- SourceItem.cs
- DataGridItemEventArgs.cs
- ToolboxDataAttribute.cs
- RedirectionProxy.cs
- SqlHelper.cs
- XPathNodePointer.cs
- Calendar.cs
- Glyph.cs
- DbProviderFactories.cs
- RootNamespaceAttribute.cs
- UserControlParser.cs
- IIS7UserPrincipal.cs
- ListCollectionView.cs
- SimpleTextLine.cs
- SqlDependencyUtils.cs
- WindowsGraphicsWrapper.cs
- Module.cs
- DataGridSortCommandEventArgs.cs
- listitem.cs
- DataGridViewCellCancelEventArgs.cs
- MouseActionConverter.cs
- WebPageTraceListener.cs