Code:
/ 4.0 / 4.0 / 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. // ==++== // // 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
- ObjectQuery_EntitySqlExtensions.cs
- TypedElement.cs
- InvokeHandlers.cs
- HttpBrowserCapabilitiesWrapper.cs
- EventSinkHelperWriter.cs
- DataGridViewLayoutData.cs
- ConnectionConsumerAttribute.cs
- SetUserPreferenceRequest.cs
- DataGridDetailsPresenterAutomationPeer.cs
- CngKeyBlobFormat.cs
- AnnotationMap.cs
- XamlRtfConverter.cs
- CodeRegionDirective.cs
- mda.cs
- ProfessionalColorTable.cs
- File.cs
- RequestCacheValidator.cs
- TimeoutException.cs
- TreeNodeBindingCollection.cs
- ExtensionQuery.cs
- CriticalExceptions.cs
- NativeMethods.cs
- RegisteredExpandoAttribute.cs
- XmlAtomicValue.cs
- RSAPKCS1KeyExchangeDeformatter.cs
- ColorConvertedBitmapExtension.cs
- NavigatorOutput.cs
- _DisconnectOverlappedAsyncResult.cs
- LogicalExpressionTypeConverter.cs
- VarRemapper.cs
- ModelChangedEventArgsImpl.cs
- AutoGeneratedField.cs
- InputBinding.cs
- KeyConverter.cs
- SmtpFailedRecipientsException.cs
- WCFBuildProvider.cs
- ZipIOEndOfCentralDirectoryBlock.cs
- RowBinding.cs
- ConfigDefinitionUpdates.cs
- ServiceElementCollection.cs
- ScriptResourceHandler.cs
- MSAAWinEventWrap.cs
- MILUtilities.cs
- FusionWrap.cs
- DisplayInformation.cs
- AnnotationResourceChangedEventArgs.cs
- RC2.cs
- SspiSecurityTokenParameters.cs
- HtmlInputPassword.cs
- DataGridViewColumnEventArgs.cs
- AutomationElementCollection.cs
- ScaleTransform3D.cs
- DoubleAverageAggregationOperator.cs
- Image.cs
- MarkupCompiler.cs
- BCLDebug.cs
- SpellerError.cs
- CodeRemoveEventStatement.cs
- ScanQueryOperator.cs
- ControllableStoryboardAction.cs
- DisplayNameAttribute.cs
- WSHttpSecurity.cs
- SQLDateTime.cs
- CommonDialog.cs
- EventDriven.cs
- InterleavedZipPartStream.cs
- WindowsStartMenu.cs
- XmlIlTypeHelper.cs
- StorageEntityContainerMapping.cs
- MetadataUtilsSmi.cs
- FileLogRecord.cs
- PageParserFilter.cs
- DataBoundControl.cs
- AttributeSetAction.cs
- TextTreeFixupNode.cs
- XmlTextEncoder.cs
- ToolboxItemImageConverter.cs
- ResourcePool.cs
- SrgsGrammarCompiler.cs
- mda.cs
- FixedSOMGroup.cs
- RequiredFieldValidator.cs
- exports.cs
- CellLabel.cs
- ButtonChrome.cs
- SchemaDeclBase.cs
- UpdateEventArgs.cs
- DataGridViewCellFormattingEventArgs.cs
- HMACRIPEMD160.cs
- NativeActivityContext.cs
- HtmlInputSubmit.cs
- OrderedDictionary.cs
- Memoizer.cs
- TypeConstant.cs
- StateWorkerRequest.cs
- MasterPageBuildProvider.cs
- EnumCodeDomSerializer.cs
- XmlReflectionMember.cs
- FormsAuthenticationModule.cs
- GeneralTransform.cs