main
 1using System;
 2
 3namespace MoMoney.Domain.Core
 4{
 5    public interface IMonth
 6    {
 7        bool represents(DateTime date);
 8    }
 9
10    [Serializable]
11    internal class Month : IMonth
12    {
13        readonly int the_underlying_month;
14        readonly string name_of_the_month;
15
16        internal Month(int month, string name_of_the_month)
17        {
18            the_underlying_month = month;
19            this.name_of_the_month = name_of_the_month;
20            Months.add(this);
21        }
22
23        public bool represents(DateTime date)
24        {
25            return date.Month.Equals(the_underlying_month);
26        }
27
28        public bool Equals(Month obj)
29        {
30            if (ReferenceEquals(null, obj)) return false;
31            if (ReferenceEquals(this, obj)) return true;
32            return obj.the_underlying_month == the_underlying_month;
33        }
34
35        public override bool Equals(object obj)
36        {
37            if (ReferenceEquals(null, obj)) return false;
38            if (ReferenceEquals(this, obj)) return true;
39            if (obj.GetType() != typeof (Month)) return false;
40            return Equals((Month) obj);
41        }
42
43        public override int GetHashCode()
44        {
45            return the_underlying_month;
46        }
47
48        public override string ToString()
49        {
50            return name_of_the_month;
51        }
52    }
53}