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
- StreamAsIStream.cs
- WindowVisualStateTracker.cs
- UIPermission.cs
- RelativeSource.cs
- Vector3DAnimation.cs
- UInt16.cs
- GenerateScriptTypeAttribute.cs
- WebPartManager.cs
- FontFamily.cs
- ScrollEventArgs.cs
- ServicePoint.cs
- PerformanceCounterLib.cs
- MethodSet.cs
- ControlIdConverter.cs
- PrintEvent.cs
- XmlAnyAttributeAttribute.cs
- DropShadowBitmapEffect.cs
- PropertyTab.cs
- HeaderPanel.cs
- AuthenticationSection.cs
- RoleGroup.cs
- SelectionHighlightInfo.cs
- WebServiceHandler.cs
- ObjectAnimationUsingKeyFrames.cs
- AssemblyBuilder.cs
- SessionPageStatePersister.cs
- EventlogProvider.cs
- TextClipboardData.cs
- Light.cs
- TraceUtility.cs
- ErrorProvider.cs
- MasterPageCodeDomTreeGenerator.cs
- ButtonFlatAdapter.cs
- GC.cs
- ClientSettingsStore.cs
- ForeignConstraint.cs
- DataSourceGeneratorException.cs
- XamlToRtfParser.cs
- CopyNamespacesAction.cs
- ReferencedCollectionType.cs
- Membership.cs
- ItemsPanelTemplate.cs
- TextBreakpoint.cs
- RuleRefElement.cs
- TargetControlTypeAttribute.cs
- ItemsPresenter.cs
- CategoryNameCollection.cs
- RepeaterItemCollection.cs
- Matrix3DStack.cs
- ConfigXmlElement.cs
- FreezableDefaultValueFactory.cs
- SerializationStore.cs
- CustomBindingCollectionElement.cs
- ComboBoxAutomationPeer.cs
- XmlSchemaSimpleTypeList.cs
- ClientSideProviderDescription.cs
- ConfigurationValidatorBase.cs
- TracedNativeMethods.cs
- XamlFigureLengthSerializer.cs
- ValueTypeIndexerReference.cs
- RowBinding.cs
- StrokeNodeData.cs
- OracleDataReader.cs
- sqlcontext.cs
- BindingOperations.cs
- Mappings.cs
- SpellCheck.cs
- SystemDiagnosticsSection.cs
- DeclaredTypeElement.cs
- BinHexDecoder.cs
- InlineUIContainer.cs
- QilCloneVisitor.cs
- HttpCapabilitiesSectionHandler.cs
- _NativeSSPI.cs
- VisualProxy.cs
- HttpCachePolicyElement.cs
- DynamicRouteExpression.cs
- Track.cs
- Compiler.cs
- ECDiffieHellman.cs
- BoundingRectTracker.cs
- GradientStop.cs
- PermissionSetEnumerator.cs
- XmlSequenceWriter.cs
- ProfileSettingsCollection.cs
- PanelStyle.cs
- Inflater.cs
- TextSelectionHighlightLayer.cs
- PassportAuthenticationEventArgs.cs
- TextRunProperties.cs
- FormViewInsertedEventArgs.cs
- XhtmlTextWriter.cs
- SerializationAttributes.cs
- ping.cs
- Form.cs
- DataServiceRequestException.cs
- ListSourceHelper.cs
- NameNode.cs
- PersistenceProviderFactory.cs
- DataGridViewColumnTypeEditor.cs