Recognize TypeConverterAttributes on properties to override default getter semantics.
[castle.git] / Core / Castle.Core / Pair.cs
blob963ff64c3f5ca5ed35ad809a7607f80270b5f713
1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle.Core
17 using System;
19 /// <summary>
20 /// General purpose class to represent a standard pair of values.
21 /// </summary>
22 /// <typeparam name="TFirst">Type of the first value</typeparam>
23 /// <typeparam name="TSecond">Type of the second value</typeparam>
24 public class Pair<TFirst, TSecond> : IEquatable<Pair<TFirst, TSecond>>
26 private readonly TFirst first;
27 private readonly TSecond second;
29 /// <summary>
30 /// Constructs a pair with its values
31 /// </summary>
32 /// <param name="first"></param>
33 /// <param name="second"></param>
34 public Pair(TFirst first, TSecond second)
36 this.first = first;
37 this.second = second;
40 public TFirst First
42 get { return first; }
45 public TSecond Second
47 get { return second; }
50 public override string ToString()
52 return first + " " + second;
55 public bool Equals(Pair<TFirst, TSecond> pair)
57 if (pair == null)
59 return false;
61 return Equals(first, pair.first) && Equals(second, pair.second);
64 public override bool Equals(object obj)
66 if (ReferenceEquals(this, obj))
68 return true;
70 return Equals(obj as Pair<TFirst, TSecond>);
73 public override int GetHashCode()
75 return first.GetHashCode() + 29 * second.GetHashCode();