main
 1using System;
 2
 3namespace jive
 4{
 5  [Serializable]
 6  public class Id<T>
 7  {
 8    static public readonly Id<T> Default = new Id<T>(default(T));
 9    readonly T id;
10
11    public Id(T id)
12    {
13      this.id = id;
14    }
15
16    static public implicit operator Id<T>(T id)
17    {
18      return new Id<T>(id);
19    }
20
21    static public implicit operator T(Id<T> id)
22    {
23      return id.id;
24    }
25
26    public bool Equals(Id<T> other)
27    {
28      if (ReferenceEquals(null, other)) return false;
29      if (ReferenceEquals(this, other)) return true;
30      return Equals(other.id, id);
31    }
32
33    public override bool Equals(object obj)
34    {
35      if (ReferenceEquals(null, obj)) return false;
36      if (ReferenceEquals(this, obj)) return true;
37      if (obj.GetType() != typeof (Id<T>)) return false;
38      return Equals((Id<T>) obj);
39    }
40
41    public override int GetHashCode()
42    {
43      return id.GetHashCode();
44    }
45  }
46}