Skip to content

Commit 009304d

Browse files
committed
Hotfix #3
Fixes #3 WorkAccountCollection no longer shows duplicate work accounts.
2 parents 0b3de13 + 19d8038 commit 009304d

File tree

5 files changed

+55
-20
lines changed

5 files changed

+55
-20
lines changed

DsReg/DsReg.psd1

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Generated by: Mike Garvey
55
#
6-
# Generated on: 8/6/2020
6+
# Generated on: 10/24/2020
77
#
88

99
@{
@@ -12,7 +12,7 @@
1212
RootModule = 'MG.DsReg.dll'
1313

1414
# Version number of this module.
15-
ModuleVersion = '1.3.0'
15+
ModuleVersion = '1.3.1'
1616

1717
# Supported PSEditions
1818
CompatiblePSEditions = @('Desktop')
@@ -115,7 +115,7 @@ PrivateData = @{
115115
# IconUri = ''
116116

117117
# ReleaseNotes of this module
118-
ReleaseNotes = 'Changes the output to make more information more readable and readiably available.'
118+
ReleaseNotes = 'Fix for Issue #3 - Duplicate work accounts in results.'
119119

120120
} # End of PSData hashtable
121121

DsReg/MG.DsReg.dll

512 Bytes
Binary file not shown.

MG.DsReg/DsRegResult.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,13 @@ public class DsRegResult : BaseDetail
4444
#region CONSTRUCTORS
4545
public DsRegResult(IEnumerable<string> allLines)
4646
{
47-
if (allLines is string[] strArr)
47+
if (allLines is ICollection<string> lineCol)
48+
{
49+
_dsRegLines = new string[lineCol.Count];
50+
lineCol.CopyTo(_dsRegLines, 0);
51+
}
52+
53+
else if (allLines is string[] strArr)
4854
_dsRegLines = strArr;
4955

5056
else

MG.DsReg/Objects/WorkAccountCollection.cs

+41-12
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,57 @@
44
using System;
55
using System.Collections;
66
using System.Collections.Generic;
7-
using System.IO;
8-
using System.Linq;
97

108
namespace MG.DsReg
119
{
1210
[Serializable]
13-
public class WorkAccountCollection : IEnumerable<WorkAccount>, IJsonOutputter
11+
public class WorkAccountCollection : IReadOnlyList<WorkAccount>, IJsonOutputter
1412
{
15-
private List<WorkAccount> _list;
13+
private SortedList<string, WorkAccount> _list;
1614

17-
public WorkAccount this[int index] => _list[index];
15+
public WorkAccount this[string tenantName] => _list[tenantName];
16+
public WorkAccount this[int index]
17+
{
18+
get
19+
{
20+
if (index >= 0)
21+
return _list.Values[index];
22+
23+
else
24+
{
25+
int goHere = _list.Count + index;
26+
return goHere >= 0 ? _list.Values[goHere] : null;
27+
}
28+
}
29+
}
1830

1931
public int Count => _list.Count;
2032

21-
public WorkAccountCollection() => _list = new List<WorkAccount>();
22-
public WorkAccountCollection(int capacity) => _list = new List<WorkAccount>(capacity);
33+
public WorkAccountCollection()
34+
{
35+
_list = new SortedList<string, WorkAccount>(StringComparer.CurrentCultureIgnoreCase);
36+
}
37+
public WorkAccountCollection(int capacity)
38+
{
39+
_list = new SortedList<string, WorkAccount>(capacity, StringComparer.CurrentCultureIgnoreCase);
40+
}
41+
42+
internal void Add(WorkAccount wa)
43+
{
44+
if (_list.ContainsKey(wa.WorkplaceTenantName))
45+
return;
2346

24-
internal void Add(WorkAccount wa) => _list.Add(wa);
47+
_list.Add(wa.WorkplaceTenantName, wa);
48+
}
2549

26-
public IEnumerator<WorkAccount> GetEnumerator() => ((IEnumerable<WorkAccount>)_list).GetEnumerator();
27-
IEnumerator IEnumerable.GetEnumerator() => ((IEnumerable<WorkAccount>)_list).GetEnumerator();
50+
public IEnumerator<WorkAccount> GetEnumerator()
51+
{
52+
return _list.Values.GetEnumerator();
53+
}
54+
IEnumerator IEnumerable.GetEnumerator()
55+
{
56+
return this.GetEnumerator();
57+
}
2858

2959
public string ToJson()
3060
{
@@ -40,10 +70,9 @@ public string ToJson()
4070
serializer.Converters.Add(new StringEnumConverter(new CamelCaseNamingStrategy()));
4171
return this.ToJson(serializer);
4272
}
43-
4473
public string ToJson(JsonSerializerSettings serializerSettings)
4574
{
46-
return JsonConvert.SerializeObject(this, serializerSettings);
75+
return JsonConvert.SerializeObject(_list.Values, serializerSettings);
4776
}
4877
}
4978
}

MG.DsReg/Properties/AssemblyInfo.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
[assembly: AssemblyTitle("MG.DsReg")]
99
[assembly: AssemblyDescription("")]
1010
[assembly: AssemblyConfiguration("")]
11-
[assembly: AssemblyCompany("")]
11+
[assembly: AssemblyCompany("Yevrag35, LLC.")]
1212
[assembly: AssemblyProduct("MG.DsReg")]
13-
[assembly: AssemblyCopyright("Copyright © 2019")]
13+
[assembly: AssemblyCopyright("Copyright © 2019-2020 Yevrag35, LLC.")]
1414
[assembly: AssemblyTrademark("")]
1515
[assembly: AssemblyCulture("")]
1616

@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.3.0")]
36-
[assembly: AssemblyFileVersion("1.3.0")]
35+
[assembly: AssemblyVersion("1.3.1")]
36+
[assembly: AssemblyFileVersion("1.3.1")]

0 commit comments

Comments
 (0)