-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebugMon.cs
109 lines (95 loc) · 3.29 KB
/
debugMon.cs
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
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)
{
//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.ReadKey();
}
else
{
//what type is the variable
if (value is string)
{
DebugString(value);
}
else if (value is int)
{
Console.WriteLine("## Debug value Integer ## Echo Value: " + value);
}
else if (value is string[])
{
DebugStringArray(value);
}
else
{
Console.WriteLine(".");
}
}
}
}
private void DebugArray(object value)
{
Console.WriteLine("## Debug value Array of Strings ## Echo Value: " + value);
}
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 String ## Echo Value: " + value);
}
private void DebugInt(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;
}
}