Skip to content

Commit 63dd3d7

Browse files
committed
* Added code comments
* Added ability to export Ram Analyzer data
1 parent 02dca77 commit 63dd3d7

File tree

6 files changed

+159
-10
lines changed

6 files changed

+159
-10
lines changed

MemPlus/Classes/EXPORT/ExportTypes.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
namespace MemPlus.Classes.EXPORT
22
{
3+
/// <summary>
4+
/// Sealed class containing all different export types that MemPlus supports
5+
/// </summary>
36
internal sealed class ExportTypes
47
{
58
/// <summary>

MemPlus/Classes/LOG/LogExporter.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace MemPlus.Classes.LOG
66
{
77
/// <summary>
8-
/// Interaction logic for exporting logs
8+
/// Static class containing the logic for exporting logs
99
/// </summary>
1010
internal static class LogExporter
1111
{
@@ -19,11 +19,11 @@ internal static void ExportHtml(string path, List<Log> logList)
1919
string exportData = "<html>";
2020

2121
exportData += "<head>";
22-
exportData += "<title>MemPlus - Export</title>";
22+
exportData += "<title>MemPlus - Log Export</title>";
2323
exportData += "</head>";
2424

2525
exportData += "<body>";
26-
exportData += "<h1>MemPlus - Export (" + DateTime.Now + ")</h1>";
26+
exportData += "<h1>MemPlus - Log Export (" + DateTime.Now + ")</h1>";
2727
exportData += "<table border=\"1\">";
2828
exportData += "<thead>";
2929
exportData += "<tr><th>Time</th><th>Data</th></tr>";
@@ -54,7 +54,7 @@ internal static void ExportHtml(string path, List<Log> logList)
5454
/// <param name="logList">The list of Log objects that should be exported</param>
5555
internal static void ExportTxt(string path, List<Log> logList)
5656
{
57-
string exportData = "MemPlus - Export (" + DateTime.Now + ")";
57+
string exportData = "MemPlus - Log Export (" + DateTime.Now + ")";
5858
exportData += Environment.NewLine;
5959

6060
for (int i = 0; i < logList.Count; i++)

MemPlus/Classes/RAM/RamAnalyzer.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Collections.Generic;
22
using System.Management;
3-
using MemPlus.Classes.RAM.ViewModels;
43

54
namespace MemPlus.Classes.RAM
65
{

MemPlus/Classes/RAM/RamStick.cs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,50 @@
11
using System.Collections.Generic;
22

3-
namespace MemPlus.Classes.RAM.ViewModels
3+
namespace MemPlus.Classes.RAM
44
{
5+
/// <summary>
6+
/// Internal sealed class containing logic behind a physical RAM stick
7+
/// </summary>
58
internal sealed class RamStick
69
{
10+
#region Variables
11+
/// <summary>
12+
/// List of data that is associated to the RAM stick
13+
/// </summary>
714
private readonly List<RamData> _ramData;
15+
#endregion
816

17+
/// <summary>
18+
/// Initialize a new RamStick object
19+
/// </summary>
920
internal RamStick()
1021
{
1122
_ramData = new List<RamData>();
1223
}
1324

25+
/// <summary>
26+
/// Add a new RamData object to the list of RamData
27+
/// </summary>
28+
/// <param name="ramData">The RamData object that needs to be added to the list</param>
1429
internal void AddRamData(RamData ramData)
1530
{
1631
_ramData.Add(ramData);
1732
}
1833

34+
/// <summary>
35+
/// Get the list of RamData objects that is associated with the RamStick object
36+
/// </summary>
37+
/// <returns>The list of RamData objects that is associated with the RamStick object</returns>
1938
internal List<RamData> GetRamData()
2039
{
2140
return _ramData;
2241
}
2342

43+
/// <summary>
44+
/// Get the value for a RamData key
45+
/// </summary>
46+
/// <param name="key">The key that needs to be found</param>
47+
/// <returns>The value for the RamData key</returns>
2448
internal string GetValue(string key)
2549
{
2650
foreach(RamData r in _ramData)
Lines changed: 127 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
23
using System.IO;
3-
using MemPlus.Classes.RAM.ViewModels;
44

55
namespace MemPlus.Classes.RAM
66
{
@@ -9,6 +9,11 @@ namespace MemPlus.Classes.RAM
99
/// </summary>
1010
internal static class RamDataExporter
1111
{
12+
/// <summary>
13+
/// Export data to a specific path
14+
/// </summary>
15+
/// <param name="path">The path where the data should be stored</param>
16+
/// <param name="data">The data that should be exported</param>
1217
private static void Export(string path, string data)
1318
{
1419
using (StreamWriter sw = new StreamWriter(path))
@@ -17,24 +22,143 @@ private static void Export(string path, string data)
1722
}
1823
}
1924

25+
/// <summary>
26+
/// Export a list of RamStick objects to a specific path in text format
27+
/// </summary>
28+
/// <param name="path">The path where the data should be stored</param>
29+
/// <param name="ramSticks">The list of RamStick objects that need to be exported</param>
2030
internal static void ExportText(string path, List<RamStick> ramSticks)
2131
{
32+
string exportData = "MemPlus - Ram Analyzer Data (" + DateTime.Now + ")";
33+
exportData += Environment.NewLine;
34+
exportData += "---";
35+
exportData += Environment.NewLine;
2236

37+
for (int index = 0; index < ramSticks.Count; index++)
38+
{
39+
RamStick stick = ramSticks[index];
40+
List<RamData> ramDataList = stick.GetRamData();
41+
for (int i = 0; i < ramDataList.Count; i++)
42+
{
43+
exportData += ramDataList[i].Key + "\t" + ramDataList[i].Value;
44+
if (i != ramDataList.Count - 1)
45+
{
46+
exportData += Environment.NewLine;
47+
}
48+
}
49+
50+
if (index != ramSticks.Count - 1)
51+
{
52+
exportData += Environment.NewLine;
53+
exportData += "----------";
54+
exportData += Environment.NewLine;
55+
}
56+
}
57+
58+
Export(path, exportData);
2359
}
2460

61+
/// <summary>
62+
/// Export a list of RamStick objects to a specific path in HTML format
63+
/// </summary>
64+
/// <param name="path">The path where the data should be stored</param>
65+
/// <param name="ramSticks">The list of RamStick objects that need to be exported</param>
2566
internal static void ExportHtml(string path, List<RamStick> ramSticks)
2667
{
68+
string exportData = "<html>";
69+
70+
exportData += "<head>";
71+
exportData += "<title>MemPlus - Ram Analyzer Data</title>";
72+
exportData += "</head>";
73+
74+
exportData += "<body>";
75+
exportData += "<h1>MemPlus - Ram Analyzer Data (" + DateTime.Now + ")</h1>";
76+
77+
for (int index = 0; index < ramSticks.Count; index++)
78+
{
79+
RamStick stick = ramSticks[index];
80+
exportData += "<table border=\"1\">";
81+
exportData += "<thead>";
82+
exportData += "<tr><th>Key</th><th>Value</th></tr>";
83+
exportData += "</thead>";
84+
exportData += "<tbody>";
85+
86+
foreach (RamData data in stick.GetRamData())
87+
{
88+
exportData += "<tr>";
89+
exportData += "<td>" + data.Key + "</td>";
90+
exportData += "<td>" + data.Value + "</td>";
91+
exportData += "</tr>";
92+
}
93+
94+
exportData += "</tbody>";
95+
exportData += "</table>";
96+
97+
if (index != ramSticks.Count - 1)
98+
{
99+
exportData += "<br />";
100+
}
101+
}
102+
103+
exportData += "</body>";
104+
105+
exportData += "</html>";
27106

107+
Export(path, exportData);
28108
}
29109

110+
/// <summary>
111+
/// Export a list of RamStick objects to a specific path in CSV format
112+
/// </summary>
113+
/// <param name="path">The path where the data should be stored</param>
114+
/// <param name="ramSticks">The list of RamStick objects that need to be exported</param>
30115
internal static void ExportCsv(string path, List<RamStick> ramSticks)
31116
{
32-
117+
ExportDelimiter(path, ",", ramSticks);
33118
}
34119

120+
/// <summary>
121+
/// Export a list of RamStick objects to a specific path in Excel format
122+
/// </summary>
123+
/// <param name="path">The path where the data should be stored</param>
124+
/// <param name="ramSticks">The list of RamStick objects that need to be exported</param>
35125
internal static void ExportExcel(string path, List<RamStick> ramSticks)
36126
{
127+
ExportDelimiter(path, ";", ramSticks);
128+
}
129+
130+
/// <summary>
131+
/// Export a list of RamStick objects using a specific delimiter character
132+
/// </summary>
133+
/// <param name="path">The path where the data should be stored</param>
134+
/// <param name="delimiter">The delimiter that should be used to split the data</param>
135+
/// <param name="ramSticks">The list of RamStick objects that need to be exported</param>
136+
private static void ExportDelimiter(string path, string delimiter, List<RamStick> ramSticks)
137+
{
138+
string exportData = "Key" + delimiter + "Value";
139+
exportData += Environment.NewLine;
140+
141+
for (int i = 0; i < ramSticks.Count; i++)
142+
{
143+
List<RamData> ramData = ramSticks[i].GetRamData();
144+
for (int index = 0; index < ramData.Count; index++)
145+
{
146+
exportData += ramData[index].Key + delimiter + ramData[index].Value;
147+
if (index != ramData.Count - 1)
148+
{
149+
exportData += Environment.NewLine;
150+
}
151+
}
152+
153+
if (i != ramSticks.Count - 1)
154+
{
155+
exportData += Environment.NewLine;
156+
exportData += "----------" + delimiter + "----------";
157+
exportData += Environment.NewLine;
158+
}
159+
}
37160

161+
Export(path, exportData);
38162
}
39163
}
40164
}

MemPlus/Windows/AnalyzerWindow.xaml.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using MemPlus.Classes.GUI;
55
using MemPlus.Classes.LOG;
66
using MemPlus.Classes.RAM;
7-
using MemPlus.Classes.RAM.ViewModels;
87
using Microsoft.Win32;
98

109
namespace MemPlus.Windows

0 commit comments

Comments
 (0)