Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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
- EntityConnection.cs
- NamespaceEmitter.cs
- WebPartConnection.cs
- UrlEncodedParameterWriter.cs
- ECDiffieHellmanCng.cs
- TrustManager.cs
- GZipStream.cs
- XmlValidatingReaderImpl.cs
- relpropertyhelper.cs
- CellIdBoolean.cs
- Encoder.cs
- HyperlinkAutomationPeer.cs
- NamedPipeChannelListener.cs
- BackEase.cs
- HtmlPanelAdapter.cs
- PopOutPanel.cs
- InteropDesigner.xaml.cs
- XmlNamedNodeMap.cs
- SelectedGridItemChangedEvent.cs
- SocketCache.cs
- ContextProperty.cs
- StringInfo.cs
- DefaultClaimSet.cs
- CreateUserWizard.cs
- ToolStripLabel.cs
- WindowsGraphics2.cs
- COM2IDispatchConverter.cs
- DatagridviewDisplayedBandsData.cs
- listitem.cs
- ToolStripHighContrastRenderer.cs
- MachineSettingsSection.cs
- CodeExporter.cs
- AuthenticodeSignatureInformation.cs
- EmbeddedObject.cs
- HttpContextWrapper.cs
- SafeRightsManagementPubHandle.cs
- MultiView.cs
- CorrelationKeyCalculator.cs
- CompositionDesigner.cs
- BevelBitmapEffect.cs
- SafeArrayRankMismatchException.cs
- TypeDescriptor.cs
- RelationshipSet.cs
- SQLMembershipProvider.cs
- XPathArrayIterator.cs
- ConfigXmlCDataSection.cs
- FontWeight.cs
- HttpModuleCollection.cs
- KernelTypeValidation.cs
- TraceUtility.cs
- Rules.cs
- IPAddressCollection.cs
- FragmentQueryKB.cs
- PointHitTestParameters.cs
- DesignerLoader.cs
- DbConnectionPool.cs
- OneOfScalarConst.cs
- UntrustedRecipientException.cs
- ScriptHandlerFactory.cs
- GlyphRunDrawing.cs
- WeakReference.cs
- SafeNativeMemoryHandle.cs
- IisNotInstalledException.cs
- MediaContextNotificationWindow.cs
- PathTooLongException.cs
- EventLogPermissionEntryCollection.cs
- SecurityTokenTypes.cs
- KeyPullup.cs
- ManifestResourceInfo.cs
- HtmlElement.cs
- RequestCachingSection.cs
- InfoCardBaseException.cs
- TickBar.cs
- PipelineComponent.cs
- unsafenativemethodstextservices.cs
- _LazyAsyncResult.cs
- DigitShape.cs
- XmlSchemaSequence.cs
- ClientApiGenerator.cs
- InitializerFacet.cs
- RegexStringValidator.cs
- Models.cs
- InternalPolicyElement.cs
- XMLDiffLoader.cs
- DataIdProcessor.cs
- BlobPersonalizationState.cs
- ConvertTextFrag.cs
- ColorContextHelper.cs
- ReadOnlyCollectionBase.cs
- ProcessHost.cs
- DataServiceProviderMethods.cs
- DesignTimeParseData.cs
- PasswordDeriveBytes.cs
- Menu.cs
- XmlEncodedRawTextWriter.cs
- HttpModuleAction.cs
- RadioButtonAutomationPeer.cs
- DataGridItemAutomationPeer.cs
- ValueQuery.cs
- StaticFileHandler.cs