fixes right button position causing right button not showing on horizontal scrollbars
[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                 public enum Accessibility
28                 {
29                         Public,
30                         Assembly,
31                         FamilyOrAssembly,
32                         Family,
33                         FamilyAndAssembly,
34                         Private,
35                 }
36
37                 /// <summary>
38                 /// The name of the element (eg "System.Xml")
39                 /// </summary>
40                 public abstract string Name { get ; }
41
42                 /// <summary>
43                 /// The type of the element (eg "namespace")
44                 /// </summary>
45                 public abstract string Type { get; }
46
47                 /// <summary>
48                 /// Generates an XmlElement describint this element
49                 /// </summary>
50                 /// <param name="doc">The document in which to create the element</param>
51                 /// <returns></returns>
52                 public virtual XmlElement CreateXML (XmlDocument doc)
53                 {
54                         XmlElement eltMissing = doc.CreateElement (Type);
55                         eltMissing.SetAttribute ("name", Name);
56                         //Status.status.SetAttributes (eltMissing);
57                         Status.SetAttributes (eltMissing);
58
59                         XmlElement eltAttributes = MissingBase.CreateMemberCollectionElement ("attributes", rgAttributes, nsAttributes, doc);
60                         if (eltAttributes != null)
61                                 eltMissing.AppendChild (eltAttributes);
62
63                         return eltMissing;
64                 }
65
66                 public virtual NodeStatus Status
67                 {
68                         get { return m_nodeStatus; }
69                 }
70
71                 public abstract NodeStatus Analyze ();
72
73                 /// <summary>
74                 /// Creates an XmlElement grouping together a set of sub-elements
75                 /// </summary>
76                 /// <param name="name">the name of the element to create</param>
77                 /// <param name="rgMembers">a list of sub-elements</param>
78                 /// <param name="doc">the document in which to create the element</param>
79                 /// <returns></returns>
80                 public static XmlElement CreateMemberCollectionElement (string name, ArrayList rgMembers, NodeStatus ns, XmlDocument doc)
81                 {
82                         XmlElement element = null;
83                         if (rgMembers != null && rgMembers.Count > 0)
84                         {
85                                 element = doc.CreateElement(name);
86                                 foreach (MissingBase mm in rgMembers)
87                                         element.AppendChild (mm.CreateXML (doc));
88
89                                 //ns.SetAttributes (element);
90                         }
91                         return element;
92                 }
93                 protected void AddFakeAttribute (bool fMono, bool fMS, string strName)
94                 {
95                         if (fMono || fMS)
96                         {
97                                 MissingAttribute ma = new MissingAttribute (
98                                         (fMono) ? strName : null,
99                                         (fMS) ? strName : null);
100                                 ma.Analyze ();
101                                 rgAttributes.Add (ma);
102                                 nsAttributes.AddChildren (ma.Status);
103                         }
104                 }
105
106                 protected void AddFlagWarning (bool fMono, bool fMS, string strName)
107                 {
108                         if (!fMono && fMS)
109                                 m_nodeStatus.AddWarning ("Should be " + strName);
110                         else if (fMono && !fMS)
111                                 m_nodeStatus.AddWarning ("Should not be " + strName);
112                 }
113
114                 protected string AccessibilityToString (Accessibility ac)
115                 {
116                         switch (ac)
117                         {
118                                 case Accessibility.Public:
119                                         return "public";
120                                 case Accessibility.Assembly:
121                                         return "internal";
122                                 case Accessibility.FamilyOrAssembly:
123                                         return "protected internal";
124                                 case Accessibility.Family:
125                                         return "protected";
126                                 case Accessibility.FamilyAndAssembly:
127                                         return "protected";     // TODO:
128                                 case Accessibility.Private:
129                                         return "private";
130                         }
131                         throw new Exception ("Invalid accessibility: "+ac.ToString ());
132                 }
133         }
134 }