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
- PageThemeCodeDomTreeGenerator.cs
- SplitterPanel.cs
- TypeForwardedToAttribute.cs
- SpStreamWrapper.cs
- DataSourceGroupCollection.cs
- SqlOuterApplyReducer.cs
- Regex.cs
- TextRunTypographyProperties.cs
- TcpSocketManager.cs
- ArraySegment.cs
- BindingExpression.cs
- TextDecorationLocationValidation.cs
- DataGridViewImageColumn.cs
- KeyGestureConverter.cs
- CatalogPartCollection.cs
- StoryFragments.cs
- MembershipValidatePasswordEventArgs.cs
- DesignerDataSchemaClass.cs
- EdmComplexTypeAttribute.cs
- TypeConverters.cs
- PowerStatus.cs
- DefaultSection.cs
- ADMembershipProvider.cs
- Converter.cs
- Exceptions.cs
- CacheMode.cs
- MaskedTextBox.cs
- OdbcConnectionHandle.cs
- XmlSubtreeReader.cs
- SQLInt64Storage.cs
- SqlDependencyUtils.cs
- ResourcePermissionBaseEntry.cs
- MarkupCompiler.cs
- SchemaElementDecl.cs
- ArgumentOutOfRangeException.cs
- XmlObjectSerializerReadContext.cs
- AssemblyCacheEntry.cs
- ExpressionStringBuilder.cs
- PopupControlService.cs
- RequestCacheValidator.cs
- SafeSystemMetrics.cs
- GridViewColumnCollection.cs
- UdpTransportBindingElement.cs
- StateDesigner.CommentLayoutGlyph.cs
- Size3D.cs
- DataGridViewTextBoxEditingControl.cs
- StyleModeStack.cs
- ForceCopyBuildProvider.cs
- ConfigurationElement.cs
- IteratorFilter.cs
- WSSecurityOneDotOneReceiveSecurityHeader.cs
- String.cs
- ConfigurationLockCollection.cs
- MediaTimeline.cs
- WaitHandle.cs
- SizeF.cs
- IncrementalReadDecoders.cs
- WindowsAltTab.cs
- Type.cs
- _HelperAsyncResults.cs
- TextParagraph.cs
- SecurityRuntime.cs
- HttpContextBase.cs
- ContentIterators.cs
- XmlWrappingReader.cs
- Camera.cs
- TypeUnloadedException.cs
- WpfSharedXamlSchemaContext.cs
- AnonymousIdentificationSection.cs
- UrlMappingCollection.cs
- LocalizationComments.cs
- GrammarBuilder.cs
- SamlAdvice.cs
- UIElementCollection.cs
- TransactionTable.cs
- ConfigurationStrings.cs
- EventlogProvider.cs
- AuthenticationModuleElement.cs
- Triplet.cs
- COM2EnumConverter.cs
- NodeLabelEditEvent.cs
- DeobfuscatingStream.cs
- CodeThrowExceptionStatement.cs
- XmlDictionaryReader.cs
- Environment.cs
- ResourceProviderFactory.cs
- ExternalFile.cs
- MailWebEventProvider.cs
- RequiredFieldValidator.cs
- CryptoApi.cs
- FontCollection.cs
- DispatcherExceptionFilterEventArgs.cs
- SystemKeyConverter.cs
- EncoderBestFitFallback.cs
- CheckBoxBaseAdapter.cs
- ProcessHostMapPath.cs
- VersionPair.cs
- TypeProvider.cs
- ThreadExceptionEvent.cs
- SystemException.cs