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
- IdentityNotMappedException.cs
- EventListener.cs
- WebPartZone.cs
- InputMethod.cs
- PartialList.cs
- EntityCommand.cs
- SortFieldComparer.cs
- ProfileBuildProvider.cs
- HttpDebugHandler.cs
- WmlCalendarAdapter.cs
- HitTestWithPointDrawingContextWalker.cs
- CodeMemberField.cs
- QuadraticBezierSegment.cs
- FormViewActionList.cs
- NavigationProperty.cs
- SocketInformation.cs
- BamlRecords.cs
- Font.cs
- AlphabeticalEnumConverter.cs
- XmlDocument.cs
- translator.cs
- HealthMonitoringSectionHelper.cs
- ExpressionVisitorHelpers.cs
- CompositeFontInfo.cs
- CircleHotSpot.cs
- Point3DCollection.cs
- ThaiBuddhistCalendar.cs
- TimeSpanStorage.cs
- OutputCacheSettings.cs
- TrackingProvider.cs
- DataTablePropertyDescriptor.cs
- SelectionHighlightInfo.cs
- SiteMap.cs
- SrgsDocumentParser.cs
- CallbackDebugBehavior.cs
- EntityDataSourceValidationException.cs
- CustomAttributeBuilder.cs
- AvTraceDetails.cs
- DataPagerField.cs
- GB18030Encoding.cs
- QuaternionAnimation.cs
- DataKey.cs
- XmlDigitalSignatureProcessor.cs
- State.cs
- AtomicFile.cs
- XmlUtf8RawTextWriter.cs
- HuffCodec.cs
- WorkflowTransactionService.cs
- ComplexTypeEmitter.cs
- DataGridPageChangedEventArgs.cs
- ExpressionPrefixAttribute.cs
- AutomationElementIdentifiers.cs
- Base64WriteStateInfo.cs
- AxHost.cs
- HelpEvent.cs
- Page.cs
- DisplayNameAttribute.cs
- QueryConverter.cs
- _Events.cs
- DataPagerFieldItem.cs
- CodeBlockBuilder.cs
- UIElement.cs
- Panel.cs
- ObjectCloneHelper.cs
- WebScriptEnablingBehavior.cs
- GlyphRunDrawing.cs
- IISMapPath.cs
- DataTemplateKey.cs
- PermissionAttributes.cs
- ColumnCollection.cs
- TextServicesContext.cs
- ConfigurationStrings.cs
- QuotedPrintableStream.cs
- EncodingInfo.cs
- RawStylusInputCustomDataList.cs
- objectresult_tresulttype.cs
- SingleObjectCollection.cs
- PlacementWorkspace.cs
- ScrollableControlDesigner.cs
- AnnotationObservableCollection.cs
- NamedPipeTransportBindingElement.cs
- Style.cs
- Margins.cs
- ObjectQuery_EntitySqlExtensions.cs
- QuaternionKeyFrameCollection.cs
- CultureInfoConverter.cs
- XmlSchemaObjectCollection.cs
- ViewManager.cs
- FrameworkElement.cs
- NotifyParentPropertyAttribute.cs
- GenericIdentity.cs
- PropertyInformationCollection.cs
- SourceFileBuildProvider.cs
- TransactionalPackage.cs
- GenericTypeParameterConverter.cs
- DriveNotFoundException.cs
- StringToken.cs
- DBConnection.cs
- IdentityVerifier.cs
- StringInfo.cs