more class status updates:
[mono.git] / mcs / tools / corcompare / MissingBase.cs
1 // Mono.Util.CorCompare.MissingBase
2 //
3 // Author(s):
4 //   Piers Haken (piersh@friskit.com)
5 //
6 // (C) 2001-2002 Piers Haken
7 using System;
8 using System.Xml;
9 using System.Reflection;
10 using System.Collections;
11
12 namespace Mono.Util.CorCompare
13 {
14         /// <summary>
15         /// Base class for all comparison items
16         /// </summary>
17         /// <remarks>
18         ///     created by - Piersh
19         ///     created on - 3/3/2002 10:23:24 AM
20         /// </remarks>
21         public abstract class MissingBase
22         {
23                 protected NodeStatus m_nodeStatus;
24                 protected ArrayList rgAttributes;
25                 protected NodeStatus nsAttributes;
26
27                 /// <summary>
28                 /// The name of the element (eg "System.Xml")
29                 /// </summary>
30                 public abstract string Name { get ; }
31
32                 /// <summary>
33                 /// The type of the element (eg "namespace")
34                 /// </summary>
35                 public abstract string Type { get; }
36
37                 /// <summary>
38                 /// Generates an XmlElement describint this element
39                 /// </summary>
40                 /// <param name="doc">The document in which to create the element</param>
41                 /// <returns></returns>
42                 public virtual XmlElement CreateXML (XmlDocument doc)
43                 {
44                         XmlElement eltMissing = doc.CreateElement (Type);
45                         eltMissing.SetAttribute ("name", Name);
46                         //Status.status.SetAttributes (eltMissing);
47                         Status.SetAttributes (eltMissing);
48
49                         XmlElement eltAttributes = MissingBase.CreateMemberCollectionElement ("attributes", rgAttributes, nsAttributes, doc);
50                         if (eltAttributes != null)
51                                 eltMissing.AppendChild (eltAttributes);
52
53                         return eltMissing;
54                 }
55
56                 public virtual NodeStatus Status
57                 {
58                         get { return m_nodeStatus; }
59                 }
60
61                 public abstract NodeStatus Analyze ();
62
63                 /// <summary>
64                 /// Creates an XmlElement grouping together a set of sub-elements
65                 /// </summary>
66                 /// <param name="name">the name of the element to create</param>
67                 /// <param name="rgMembers">a list of sub-elements</param>
68                 /// <param name="doc">the document in which to create the element</param>
69                 /// <returns></returns>
70                 public static XmlElement CreateMemberCollectionElement (string name, ArrayList rgMembers, NodeStatus ns, XmlDocument doc)
71                 {
72                         XmlElement element = null;
73                         if (rgMembers != null && rgMembers.Count > 0)
74                         {
75                                 element = doc.CreateElement(name);
76                                 foreach (MissingBase mm in rgMembers)
77                                         element.AppendChild (mm.CreateXML (doc));
78
79                                 //ns.SetAttributes (element);
80                         }
81                         return element;
82                 }
83                 protected void AddFakeAttribute (bool fMono, bool fMS, string strName)
84                 {
85                         if (fMono || fMS)
86                         {
87                                 MissingAttribute ma = new MissingAttribute (
88                                         (fMono) ? strName : null,
89                                         (fMS) ? strName : null);
90                                 ma.Analyze ();
91                                 rgAttributes.Add (ma);
92                                 nsAttributes.AddChildren (ma.Status);
93                         }
94                 }
95         }
96 }