Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntity / System / Data / Common / Utils / Pair.cs / 1305376 / 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
- InputLangChangeRequestEvent.cs
- SafeArchiveContext.cs
- DataErrorValidationRule.cs
- CompositeFontInfo.cs
- UIHelper.cs
- InfoCardSymmetricCrypto.cs
- ScriptReference.cs
- UIElementCollection.cs
- Package.cs
- EventProperty.cs
- MetaChildrenColumn.cs
- HttpResponseMessageProperty.cs
- XmlSchemaObjectCollection.cs
- RenderContext.cs
- PointAnimationUsingPath.cs
- OdbcConnectionFactory.cs
- CharacterBuffer.cs
- WebRequestModuleElement.cs
- QilNode.cs
- BinHexEncoder.cs
- XmlEnumAttribute.cs
- ClockController.cs
- Span.cs
- PrintPageEvent.cs
- JsonFormatGeneratorStatics.cs
- WrappedIUnknown.cs
- PluralizationServiceUtil.cs
- GraphicsState.cs
- ClockController.cs
- _ListenerAsyncResult.cs
- QilCloneVisitor.cs
- Button.cs
- ToolStripPanelRow.cs
- XPathDocumentNavigator.cs
- PointCollectionConverter.cs
- HtmlMeta.cs
- MenuItemAutomationPeer.cs
- AsyncCompletedEventArgs.cs
- TimeSpanConverter.cs
- AsyncContentLoadedEventArgs.cs
- DataSysAttribute.cs
- PropertyPathWorker.cs
- ContentType.cs
- SkewTransform.cs
- OutOfMemoryException.cs
- PropertySet.cs
- RowToParametersTransformer.cs
- WindowsStartMenu.cs
- SQLConvert.cs
- MetadataArtifactLoader.cs
- WebPartZone.cs
- SymbolDocumentGenerator.cs
- HtmlInputReset.cs
- ParserExtension.cs
- Rotation3DAnimationUsingKeyFrames.cs
- OleDbInfoMessageEvent.cs
- contentDescriptor.cs
- CollectionViewProxy.cs
- IgnoreSectionHandler.cs
- FormsAuthenticationCredentials.cs
- SharedStatics.cs
- ExtentCqlBlock.cs
- ApplicationSecurityManager.cs
- wgx_exports.cs
- PackWebRequest.cs
- FormsAuthenticationCredentials.cs
- Accessors.cs
- RoutedEventConverter.cs
- DefaultClaimSet.cs
- RawStylusSystemGestureInputReport.cs
- ObjectSet.cs
- Zone.cs
- XmlAttributeCache.cs
- UIElementPropertyUndoUnit.cs
- DefaultParameterValueAttribute.cs
- RemotingAttributes.cs
- XmlILOptimizerVisitor.cs
- StatusBarDrawItemEvent.cs
- DocumentPageHost.cs
- StoragePropertyMapping.cs
- DataGridViewRowsAddedEventArgs.cs
- FixUpCollection.cs
- Point3DValueSerializer.cs
- ConfigurationValues.cs
- ProviderConnectionPoint.cs
- BevelBitmapEffect.cs
- DynamicResourceExtensionConverter.cs
- DefaultIfEmptyQueryOperator.cs
- ViewGenerator.cs
- mda.cs
- DefaultObjectMappingItemCollection.cs
- RepeaterCommandEventArgs.cs
- InvalidPropValue.cs
- DropSource.cs
- PeerNameRecordCollection.cs
- NewArray.cs
- PerformanceCounterPermissionEntryCollection.cs
- ReferencedCollectionType.cs
- XPathNavigator.cs
- PermissionSet.cs