Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / ndp / fx / src / DataEntity / System / Data / Common / Utils / Pair.cs / 1 / Pair.cs
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.Linq;
namespace System.Data.Common.Utils
{
internal class Pair : InternalBase
{
#region Fields
private readonly TFirst first;
private readonly TSecond second;
#endregion
#region Constructor
internal Pair(TFirst first, TSecond second)
{
this.first = first;
this.second = second;
}
#endregion
#region Properties
internal TFirst First
{
get
{
return first;
}
}
internal TSecond Second
{
get
{
return second;
}
}
#endregion
#region Methods
public override int GetHashCode()
{
return (first.GetHashCode()<<5) ^ second.GetHashCode();
}
public bool Equals(Pair other)
{
return first.Equals(other.first) && second.Equals(other.second);
}
public override bool Equals(object other)
{
Pair otherPair = other as Pair;
return (otherPair != null && Equals(otherPair));
}
#endregion
#region InternalBase
internal override void ToCompactString(StringBuilder builder)
{
builder.Append("<");
builder.Append(first.ToString());
builder.Append(", "+second.ToString());
builder.Append(">");
}
#endregion
internal class PairComparer : IEqualityComparer>
{
private PairComparer() { }
internal static readonly PairComparer Instance = new PairComparer();
private static readonly EqualityComparer firstComparer = EqualityComparer.Default;
private static readonly EqualityComparer secondComparer = EqualityComparer.Default;
public bool Equals(Pair x, Pair y)
{
return firstComparer.Equals(x.First, y.First) && secondComparer.Equals(x.Second, y.Second);
}
public int GetHashCode(Pair source)
{
return source.GetHashCode();
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.Linq;
namespace System.Data.Common.Utils
{
internal class Pair : InternalBase
{
#region Fields
private readonly TFirst first;
private readonly TSecond second;
#endregion
#region Constructor
internal Pair(TFirst first, TSecond second)
{
this.first = first;
this.second = second;
}
#endregion
#region Properties
internal TFirst First
{
get
{
return first;
}
}
internal TSecond Second
{
get
{
return second;
}
}
#endregion
#region Methods
public override int GetHashCode()
{
return (first.GetHashCode()<<5) ^ second.GetHashCode();
}
public bool Equals(Pair other)
{
return first.Equals(other.first) && second.Equals(other.second);
}
public override bool Equals(object other)
{
Pair otherPair = other as Pair;
return (otherPair != null && Equals(otherPair));
}
#endregion
#region InternalBase
internal override void ToCompactString(StringBuilder builder)
{
builder.Append("<");
builder.Append(first.ToString());
builder.Append(", "+second.ToString());
builder.Append(">");
}
#endregion
internal class PairComparer : IEqualityComparer>
{
private PairComparer() { }
internal static readonly PairComparer Instance = new PairComparer();
private static readonly EqualityComparer firstComparer = EqualityComparer.Default;
private static readonly EqualityComparer secondComparer = EqualityComparer.Default;
public bool Equals(Pair x, Pair y)
{
return firstComparer.Equals(x.First, y.First) && secondComparer.Equals(x.Second, y.Second);
}
public int GetHashCode(Pair source)
{
return source.GetHashCode();
}
}
}
}
// 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
- MimeWriter.cs
- DocumentApplicationJournalEntryEventArgs.cs
- WorkflowMarkupSerializationManager.cs
- InstanceDataCollection.cs
- WindowsAuthenticationEventArgs.cs
- HopperCache.cs
- ConvertBinder.cs
- HyperLinkField.cs
- SplashScreenNativeMethods.cs
- ToolStripTextBox.cs
- WinInetCache.cs
- mil_commands.cs
- WebServiceHandlerFactory.cs
- EditCommandColumn.cs
- View.cs
- Panel.cs
- CharEnumerator.cs
- RepeatInfo.cs
- ScrollPatternIdentifiers.cs
- RegexTree.cs
- _ListenerRequestStream.cs
- ControlType.cs
- ThousandthOfEmRealDoubles.cs
- XmlAnyElementAttributes.cs
- CacheSection.cs
- UnsafeCollabNativeMethods.cs
- BitmapEffect.cs
- TextTabProperties.cs
- Help.cs
- SQLUtility.cs
- ListControl.cs
- ToolStripComboBox.cs
- SafeHandle.cs
- CellLabel.cs
- DynamicMetaObjectBinder.cs
- MulticastDelegate.cs
- SoapSchemaExporter.cs
- DataColumnSelectionConverter.cs
- ChannelServices.cs
- ObjectStateEntryDbDataRecord.cs
- HttpModulesSection.cs
- JsonReaderWriterFactory.cs
- CodeRemoveEventStatement.cs
- BitmapEffectInput.cs
- EventProviderWriter.cs
- PageContent.cs
- WindowsListViewGroupSubsetLink.cs
- AnnotationAuthorChangedEventArgs.cs
- XmlSchemaObjectCollection.cs
- ImageConverter.cs
- CodeCatchClause.cs
- ToolStripItemTextRenderEventArgs.cs
- Pkcs7Signer.cs
- EventLogPermissionEntry.cs
- AuthStoreRoleProvider.cs
- SafeIUnknown.cs
- MetabaseSettingsIis7.cs
- figurelengthconverter.cs
- SessionSwitchEventArgs.cs
- SerializationEventsCache.cs
- CLSCompliantAttribute.cs
- DataGridRelationshipRow.cs
- ChangeTracker.cs
- ListBindableAttribute.cs
- FixUp.cs
- WindowsListViewSubItem.cs
- DependencyPropertyChangedEventArgs.cs
- HandlerFactoryCache.cs
- TextContainerChangeEventArgs.cs
- AcceleratedTokenProvider.cs
- XPathSelectionIterator.cs
- ImportContext.cs
- EndpointFilterProvider.cs
- SqlGenerator.cs
- GregorianCalendarHelper.cs
- DataChangedEventManager.cs
- XslAst.cs
- XmlElementAttribute.cs
- EnumMemberAttribute.cs
- InfoCardAsymmetricCrypto.cs
- AtomParser.cs
- RuleAttributes.cs
- DataMemberAttribute.cs
- Point3D.cs
- SrgsOneOf.cs
- KeyEventArgs.cs
- MenuRendererClassic.cs
- AttributedMetaModel.cs
- SuppressMergeCheckAttribute.cs
- SafeRegistryKey.cs
- CodeDOMUtility.cs
- NameTable.cs
- ExistsInCollection.cs
- ZoneButton.cs
- x509store.cs
- HttpCachePolicyBase.cs
- KeyGestureValueSerializer.cs
- FactoryGenerator.cs
- ArraySegment.cs
- MarkupCompilePass1.cs