-
Notifications
You must be signed in to change notification settings - Fork 0
/
Auditor.cs
68 lines (61 loc) · 1.77 KB
/
Auditor.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
using System;
using System.Collections;
using System.IO;
namespace IllySystems
{
public class Auditor
{
//can specify the path here
public string PathToOutPutChange = string.Empty;
public Hashtable CompareObjects(ObjectA objecta, ObjectB objectb)
{
Hashtable changeHtable = new Hashtable();
int counter = 0;
foreach (DictionaryEntry entryA in objecta.GetHashtable())
{
foreach (DictionaryEntry entryB in objectb.GetHashtable())
{
if ((entryA.Key.Equals(entryB.Key)) && (!entryA.Value.Equals(entryB.Value)))
{
counter++;
changeHtable.Add(entryA.Key, "Change "+ counter +": "+ "Object_A: " + entryA.Value + " || Object_B: " + entryB.Value + " ");
}
}
}
WriteDifference(changeHtable);
WriteDifferenceToStream(changeHtable);
return changeHtable;
}
private void WriteDifference(Hashtable changeHt)
{
if (changeHt.Count != 0)
{
Console.WriteLine("Change are:");
foreach (DictionaryEntry entrywithchanges in changeHt)
{
Console.WriteLine(entrywithchanges.Key);
Console.WriteLine(entrywithchanges.Value);
}
}
else
{
Console.WriteLine("There is no change.");
}
}
private void WriteDifferenceToStream(Hashtable changeHt)
{
if (changeHt.Count != 0)
{
using (StreamWriter changefile = new StreamWriter(@"change.txt", true))
{
foreach (DictionaryEntry entrywithchanges in changeHt)
{
changefile.WriteLine("Change are:");
changefile.WriteLine(entrywithchanges.Key);
changefile.WriteLine(entrywithchanges.Value);
}
}
}
}
}
}