merging the Mainsoft branch to the trunk
[mono.git] / mcs / tools / corcompare / MissingEvent.cs
1 // Mono.Util.CorCompare.MissingEvent
2 //
3 // Author(s):
4 //   Nick Drochak (ndrochak@gol.com)
5 //
6 // (C) 2001-2002 Nick Drochak
7
8 using System;
9 using System.Reflection;
10 using System.Xml;
11
12 namespace Mono.Util.CorCompare {
13
14         /// <summary>
15         ///     Represents a class event that is completely missing
16         /// </summary>
17         /// <remarks>
18         ///     created by - Nick
19         ///     created on - 2/24/2002 10:43:57 PM
20         /// </remarks>
21         class MissingEvent : MissingMember {
22                 // e.g. <method name="Equals" status="missing"/>
23                 public MissingEvent (MemberInfo infoMono, MemberInfo infoMS) : base (infoMono, infoMS) {}
24                 MissingMethod mmAdd;
25                 MissingMethod mmRemove;
26                 MissingMethod mmRaise;
27
28                 public override string Type {
29                         get {
30                                 return "event";
31                         }
32                 }
33
34                 public override NodeStatus Analyze ()
35                 {
36                         m_nodeStatus = base.Analyze ();
37
38                         EventInfo eiMono = (EventInfo) mInfoMono;
39                         EventInfo eiMS   = (EventInfo) mInfoMS;
40
41                         MemberInfo miAddMono, miRemoveMono, miRaiseMono;
42                         if (eiMono == null)
43                                 miAddMono = miRemoveMono = miRaiseMono = null;
44                         else
45                         {
46                                 miAddMono = eiMono.GetAddMethod ();
47                                 miRemoveMono = eiMono.GetRemoveMethod ();
48                                 miRaiseMono = eiMono.GetRaiseMethod ();
49                         }
50
51                         MemberInfo miAddMS, miRemoveMS, miRaiseMS;
52                         if (eiMS == null)
53                                 miAddMS = miRemoveMS = miRaiseMS = null;
54                         else
55                         {
56                                 miAddMS = eiMS.GetAddMethod ();
57                                 miRemoveMS = eiMS.GetRemoveMethod ();
58                                 miRaiseMS = eiMS.GetRaiseMethod ();
59                         }
60
61                         if (miAddMono != null || miAddMS != null)
62                         {
63                                 mmAdd = new MissingMethod (miAddMono, miAddMS);
64                                 m_nodeStatus.AddChildren (mmAdd.Analyze ());
65                         }
66                         if (miRemoveMono != null || miRemoveMS != null)
67                         {
68                                 mmRemove = new MissingMethod (miRemoveMono, miRemoveMS);
69                                 m_nodeStatus.AddChildren (mmRemove.Analyze ());
70                         }
71                         if (miRaiseMono != null || miRaiseMS != null)
72                         {
73                                 mmRaise = new MissingMethod (miRemoveMono, miRemoveMS);
74                                 m_nodeStatus.AddChildren (mmRaise.Analyze ());
75                         }
76                         return m_nodeStatus;
77                 }
78
79                 public override XmlElement CreateXML (XmlDocument doc)
80                 {
81                         XmlElement eltMember = base.CreateXML (doc);
82
83                         if (mInfoMono != null && mmRaise != null)
84                         {
85                                 XmlElement eltAccessors = (XmlElement) eltMember.SelectSingleNode ("accessors");
86                                 if (eltAccessors == null)
87                                 {
88                                         eltAccessors = doc.CreateElement ("accessors");
89                                         eltMember.AppendChild (eltAccessors);
90                                 }
91                                 if (mmAdd != null)
92                                 {
93                                         XmlElement eltAdd = mmAdd.CreateXML (doc);
94                                         eltAccessors.AppendChild (eltAdd);
95                                 }
96                                 if (mmRemove != null)
97                                 {
98                                         XmlElement eltRemove = mmRemove.CreateXML (doc);
99                                         eltAccessors.AppendChild (eltRemove);
100                                 }
101                                 if (mmRaise != null)
102                                 {
103                                         XmlElement eltRaise = mmRaise.CreateXML (doc);
104                                         eltAccessors.AppendChild (eltRaise);
105                                 }
106                         }
107                         return eltMember;
108                 }
109         }
110 }