2003-06-12 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
[mono.git] / mcs / class / System / System.ComponentModel.Design / CommandID.cs
1 //
2 // System.ComponentModel.Design.CommandID.cs
3 //
4 // Author:
5 //   Alejandro Sánchez Acosta  <raciel@es.gnu.org>
6 //   Andreas Nahr (ClassDevelopment@A-SoftTech.com)
7 //
8 // (C) Alejandro Sánchez Acosta
9 // (C) 2003 Andreas Nahr
10 // 
11
12 using System.Runtime.InteropServices;
13
14 namespace System.ComponentModel.Design
15 {
16         [ComVisible(true)]
17         public class CommandID
18         {
19                 private int cID;
20                 private Guid guid;
21
22                 public CommandID (Guid menuGroup, int commandID)
23                 {
24                         cID = commandID;
25                         guid = menuGroup;
26                 }
27
28                 public virtual Guid Guid {
29                         get {
30                                 return guid;
31                         }
32                 }
33
34                 public virtual int ID {
35                         get {
36                                 return cID;
37                         }
38                 }
39
40                 public override bool Equals (object obj)
41                 {
42                         if (!(obj is CommandID))
43                                 return false;
44                         if (obj == this)
45                                 return true;
46                         return ((CommandID) obj).Guid.Equals (guid) && 
47                                 ((CommandID) obj).ID.Equals (cID);
48                 }
49
50                 public override int GetHashCode() 
51                 {
52                         // Guid can only be valid
53                         return guid.GetHashCode() ^ cID.GetHashCode();
54                 }
55
56                 public override string ToString()
57                 {
58                         return guid.ToString () + " : " + cID.ToString ();
59                 }
60         }
61 }