-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebugMon.cs
More file actions
169 lines (143 loc) · 5.15 KB
/
debugMon.cs
File metadata and controls
169 lines (143 loc) · 5.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
using System;
using System.IO;
using System.Linq;
using System.Xml.Linq;
using System.Xml;
public class DebugMon
{
//Takes a variable that is passed to it and outputs the contents so that its value can be debug'd
//would be nice to create a dynamic class that figures out what the variable type is and then does something with it
//so if I pass an array it sends it to teh array instead of the int method.
//class main entry method
public void DebugVariable(object value)
{
//method needs to take an unknown variable of any type or generate a method for each variable type to be debugged
//**Add bool switch 1 or 0 to main method entry point for class if 1 go ahead if 2 ignore
public bool TurnOnDebug()
{
bool debugOnOff = false;
//Console.WriteLine("bool should be false " + debugOnOff);
//get xml file as per debug folder for build
string xmlFile = File.ReadAllText(@"Config.xml");
//assign that file to teh xmldoc constructor
XmlDocument xmldoc = new XmlDocument();
xmldoc.LoadXml(xmlFile);
XmlNodeList nodeList = xmldoc.GetElementsByTagName("debugSwitch");
//go throguh all nodes find debugSwitch and assign as relevant
foreach (XmlNode node in nodeList)
{
if (node.InnerText == "false")
{
debugOnOff = false;
}
else if (node.InnerText == "true")
{
debugOnOff = true;
}
}
//return the debug switch as bool
return debugOnOff;
}
public void ValVariable(object value)
{
//check if we have debugging turned on or not
if (TurnOnDebug() != true)
{
//do nothing
Console.WriteLine("Debugging is turned off.");
//Console.ReadKey();
}
else
{
//this should really be a seperate class or line of code for validation.
//perform required actions
if (value == null)
{
Console.WriteLine("The variable requesting debug is empty.");
Console.WriteLine("Nothing to do here program will exit.");
Console.ReadKey();
}
else
{
//perform required actions
if (value != null)
{
Console.WriteLine("Nothing to do here program will exit.");
Console.ReadKey();
}
else
{
//what type is the variable
if (value is string)
{
DebugString(value);
}
else if (value is int)
{
DebugInt(value);
}
else if (value is string[])
{
DebugStringArray(value);
}
else
{
Console.WriteLine("## Variable cannot be debugged ##");
{
//if value.GetType() =
//if string or array of strings then do
DebugString(value);
//DebugArray(value);
}
else if (value is int)
{
Console.WriteLine("## Debug value Integer ## Echo Value: " + value);
}
else
{
Console.WriteLine(".");
}
}
}
}
private void DebugString(object value)
{
Console.WriteLine("## Debug value String ## Echo Value: " + value);
}
private void DebugStringArray(object value)
{
//for(int n=0; n < )
Console.WriteLine("## Debug value Array of Strings ## Echo Value: " + value);
}
private void DebugInt(object value)
{
Console.WriteLine("## Debug value Integer ## Echo Value: " + value);
}
//method needs to take an unknown variable of any type or generate a method for each variable type to be debugged
//**Add bool switch 1 or 0 to main method entry point for class if 1 go ahead if 2 ignore
public bool TurnOnDebug()
{
bool debugOnOff = false;
//Console.WriteLine("bool should be false " + debugOnOff);
//get xml file as per debug folder for build
string xmlFile = File.ReadAllText(@"Config.xml");
//assign that file to teh xmldoc constructor
XmlDocument xmldoc = new XmlDocument();
xmldoc.LoadXml(xmlFile);
XmlNodeList nodeList = xmldoc.GetElementsByTagName("debugSwitch");
//go throguh all nodes find debugSwitch and assign as relevant
foreach (XmlNode node in nodeList)
{
if (node.InnerText == "false")
{
debugOnOff = false;
}
else if (node.InnerText == "true")
{
debugOnOff = true;
}
}
//return the debug switch as bool
return debugOnOff;
}
}