WIP
DirectOutput framework for virtual pinball cabinets WIP
Go to:
Overview 
VSXmlDocu.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Xml;
6 
7 namespace DocumentationHelper
8 {
9  public static class VSXmlDocu
10  {
11  public static Dictionary<string, string> TypeSummary = new Dictionary<string, string>();
12  public static Dictionary<string, string> PropertySummary = new Dictionary<string, string>();
13  public static Dictionary<string, string> PropertyValue = new Dictionary<string, string>();
14  public static Dictionary<string, string> EnumSummary = new Dictionary<string, string>();
15 
16  static VSXmlDocu()
17  {
18  Load();
19  }
20 
21 
22  private static string Unindent(string S)
23  {
24  if (S.StartsWith("\r\n"))
25  {
26  S = S.Substring(2);
27  }
28  int L = 0;
29  for (int i = 0; i < S.Length; i++)
30  {
31  if (S.Substring(i, 1) != " ")
32  {
33  L = i;
34  break;
35  }
36 
37  }
38  if (L > 0)
39  {
40  string Spaces = new string(' ', L);
41 
42  string X = "";
43  string Y = "";
44  foreach (string A in S.Split('\n'))
45  {
46  X = A.Replace("\r", "");
47  if (X.StartsWith(Spaces))
48  {
49  X = X.Substring(L);
50  }
51  X = X.TrimEnd();
52  X = X + "\n";
53  Y += X;
54  }
55  return Y;
56  }
57  return S;
58 
59 
60  }
61 
62  public static void Load()
63  {
64  XmlDocument doc = new XmlDocument();
65  doc.Load(@"DirectOutput.XML");
66 
67 
68  XmlNode docNode = null;
69  foreach (XmlNode N in doc.ChildNodes)
70  {
71  docNode = N;
72  if (N.Name == "doc") break;
73  }
74 
75  if (docNode == null) return;
76  XmlNode membersNode = null;
77  foreach (XmlNode N in docNode.ChildNodes)
78  {
79  membersNode = N;
80  if (N.Name == "members") break;
81  }
82 
83  if (membersNode == null) return;
84 
85  foreach (XmlNode M in membersNode)
86  {
87  if (M.Attributes != null)
88  {
89  string Name = "";
90 
91  foreach (XmlAttribute A in M.Attributes)
92  {
93  if (A.Name == "name")
94  {
95  Name = A.Value;
96  break;
97  }
98  }
99 
100  if (Name.StartsWith("T:"))
101  {
102  //Its a type
103  Name = Name.Substring(2);
104 
105  foreach (XmlNode TChild in M.ChildNodes)
106  {
107  switch (TChild.Name)
108  {
109  case "summary":
110  TypeSummary.Add(Name, Unindent(TChild.InnerXml));
111  break;
112  case "remarks":
113  case "param":
114  break;
115  default:
116  break;
117  }
118 
119 
120  }
121 
122 
123  }
124  else if (Name.StartsWith("P:"))
125  {
126  //Property
127  Name = Name.Substring(2);
128 
129  foreach (XmlNode TChild in M.ChildNodes)
130  {
131  switch (TChild.Name)
132  {
133  case "summary":
134  PropertySummary.Add(Name, Unindent(TChild.InnerXml));
135  break;
136  case "value":
137  PropertyValue.Add(Name, Unindent(TChild.InnerXml));
138  break;
139  case "param":
140  // PropertyParam.Add(Name, TChild.InnerXml.Replace("\r\n", ""));
141  break;
142  case "returns":
143  case "exception":
144  case "#text":
145  case "note":
146  break;
147  default:
148  break;
149  }
150 
151 
152  }
153  }
154  else if (Name.StartsWith("F:"))
155  {
156  Name = Name.Substring(2);
157  //Enum
158  foreach (XmlNode TChild in M.ChildNodes)
159  {
160  switch (TChild.Name)
161  {
162  case "summary":
163  EnumSummary.Add(Name, Unindent(TChild.InnerXml));
164  break;
165  default:
166  break;
167  }
168 
169 
170  }
171  }
172 
173  }
174 
175 
176 
177 
178  }
179 
180 
181 
182 
183  }
184  }
185 }