From 168dc9f68a6f95e1017c3f310d416a279333bfdd Mon Sep 17 00:00:00 2001 From: hammett Date: Sun, 5 Aug 2007 02:54:22 +0000 Subject: [PATCH] Added general purpose Pair class git-svn-id: https://svn.castleproject.org/svn/castle/trunk@4086 73e77b4c-caa6-f847-a29a-24ab75ae54b6 --- Core/Castle.Core/Castle.Core-vs2005.csproj | 1 + Core/Castle.Core/Pair.cs | 78 ++++++++++++++++++++++++++++++ Core/Changes.txt | 2 + 3 files changed, 81 insertions(+) create mode 100644 Core/Castle.Core/Pair.cs diff --git a/Core/Castle.Core/Castle.Core-vs2005.csproj b/Core/Castle.Core/Castle.Core-vs2005.csproj index 7f50f8dc7..0d628f142 100644 --- a/Core/Castle.Core/Castle.Core-vs2005.csproj +++ b/Core/Castle.Core/Castle.Core-vs2005.csproj @@ -104,6 +104,7 @@ + diff --git a/Core/Castle.Core/Pair.cs b/Core/Castle.Core/Pair.cs new file mode 100644 index 000000000..963ff64c3 --- /dev/null +++ b/Core/Castle.Core/Pair.cs @@ -0,0 +1,78 @@ +// Copyright 2004-2007 Castle Project - http://www.castleproject.org/ +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Castle.Core +{ + using System; + + /// + /// General purpose class to represent a standard pair of values. + /// + /// Type of the first value + /// Type of the second value + public class Pair : IEquatable> + { + private readonly TFirst first; + private readonly TSecond second; + + /// + /// Constructs a pair with its values + /// + /// + /// + public Pair(TFirst first, TSecond second) + { + this.first = first; + this.second = second; + } + + public TFirst First + { + get { return first; } + } + + public TSecond Second + { + get { return second; } + } + + public override string ToString() + { + return first + " " + second; + } + + public bool Equals(Pair pair) + { + if (pair == null) + { + return false; + } + return Equals(first, pair.first) && Equals(second, pair.second); + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(this, obj)) + { + return true; + } + return Equals(obj as Pair); + } + + public override int GetHashCode() + { + return first.GetHashCode() + 29 * second.GetHashCode(); + } + } +} diff --git a/Core/Changes.txt b/Core/Changes.txt index 52212c4d7..901a03f83 100644 --- a/Core/Changes.txt +++ b/Core/Changes.txt @@ -1,6 +1,8 @@ Release Candidate 3 =================== +- Added Pair class. + - Applied Bill Pierce's patch fixing CORE-9 "Allow CastleComponent Attribute to Specify Lifestyle in Constructor" -- 2.11.4.GIT