aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Data/WindowsInstaller/TableIndexedCollection.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/WixToolset.Data/WindowsInstaller/TableIndexedCollection.cs')
-rw-r--r--src/WixToolset.Data/WindowsInstaller/TableIndexedCollection.cs62
1 files changed, 12 insertions, 50 deletions
diff --git a/src/WixToolset.Data/WindowsInstaller/TableIndexedCollection.cs b/src/WixToolset.Data/WindowsInstaller/TableIndexedCollection.cs
index 57ba19d1..a399c6fa 100644
--- a/src/WixToolset.Data/WindowsInstaller/TableIndexedCollection.cs
+++ b/src/WixToolset.Data/WindowsInstaller/TableIndexedCollection.cs
@@ -15,19 +15,13 @@ namespace WixToolset.Data.WindowsInstaller
15 /// <summary> 15 /// <summary>
16 /// Instantiate a new empty collection. 16 /// Instantiate a new empty collection.
17 /// </summary> 17 /// </summary>
18 public TableIndexedCollection() 18 public TableIndexedCollection() => this.collection = new Dictionary<string, Table>();
19 {
20 this.collection = new Dictionary<string, Table>();
21 }
22 19
23 /// <summary> 20 /// <summary>
24 /// Instantiate a new collection populated with a set of tables. 21 /// Instantiate a new collection populated with a set of tables.
25 /// </summary> 22 /// </summary>
26 /// <param name="tables">Set of tables.</param> 23 /// <param name="tables">Set of tables.</param>
27 public TableIndexedCollection(IEnumerable<Table> tables) 24 public TableIndexedCollection(IEnumerable<Table> tables) => this.collection = tables.ToDictionary(t => t.Name);
28 {
29 this.collection = tables.ToDictionary(t => t.Name);
30 }
31 25
32 /// <summary> 26 /// <summary>
33 /// Gets the number of items in the collection. 27 /// Gets the number of items in the collection.
@@ -45,18 +39,12 @@ namespace WixToolset.Data.WindowsInstaller
45 /// </summary> 39 /// </summary>
46 /// <param name="table">Table to add to the collection.</param> 40 /// <param name="table">Table to add to the collection.</param>
47 /// <remarks>Indexes the table by name.</remarks> 41 /// <remarks>Indexes the table by name.</remarks>
48 public void Add(Table table) 42 public void Add(Table table) => this.collection.Add(table.Name, table);
49 {
50 this.collection.Add(table.Name, table);
51 }
52 43
53 /// <summary> 44 /// <summary>
54 /// Clear the tables from the collection. 45 /// Clear the tables from the collection.
55 /// </summary> 46 /// </summary>
56 public void Clear() 47 public void Clear() => this.collection.Clear();
57 {
58 this.collection.Clear();
59 }
60 48
61 /// <summary> 49 /// <summary>
62 /// Determines if a table is in the collection. 50 /// Determines if a table is in the collection.
@@ -70,46 +58,31 @@ namespace WixToolset.Data.WindowsInstaller
70 /// </summary> 58 /// </summary>
71 /// <param name="array">Array to copy the collection into.</param> 59 /// <param name="array">Array to copy the collection into.</param>
72 /// <param name="arrayIndex">Index to start copying from.</param> 60 /// <param name="arrayIndex">Index to start copying from.</param>
73 public void CopyTo(Table[] array, int arrayIndex) 61 public void CopyTo(Table[] array, int arrayIndex) => this.collection.Values.CopyTo(array, arrayIndex);
74 {
75 this.collection.Values.CopyTo(array, arrayIndex);
76 }
77 62
78 /// <summary> 63 /// <summary>
79 /// Remove a table from the collection by name. 64 /// Remove a table from the collection by name.
80 /// </summary> 65 /// </summary>
81 /// <param name="tableName">Table name to remove from the collection.</param> 66 /// <param name="tableName">Table name to remove from the collection.</param>
82 public void Remove(string tableName) 67 public void Remove(string tableName) => _ = this.collection.Remove(tableName);
83 {
84 this.collection.Remove(tableName);
85 }
86 68
87 /// <summary> 69 /// <summary>
88 /// Remove a table from the collection. 70 /// Remove a table from the collection.
89 /// </summary> 71 /// </summary>
90 /// <param name="table">Table with matching name to remove from the collection.</param> 72 /// <param name="table">Table with matching name to remove from the collection.</param>
91 public bool Remove(Table table) 73 public bool Remove(Table table) => this.collection.Remove(table.Name);
92 {
93 return this.collection.Remove(table.Name);
94 }
95 74
96 /// <summary> 75 /// <summary>
97 /// Gets an enumerator over the whole collection. 76 /// Gets an enumerator over the whole collection.
98 /// </summary> 77 /// </summary>
99 /// <returns>Collection enumerator.</returns> 78 /// <returns>Collection enumerator.</returns>
100 public IEnumerator<Table> GetEnumerator() 79 public IEnumerator<Table> GetEnumerator() => this.collection.Values.GetEnumerator();
101 {
102 return this.collection.Values.GetEnumerator();
103 }
104 80
105 /// <summary> 81 /// <summary>
106 /// Gets an untyped enumerator over the whole collection. 82 /// Gets an untyped enumerator over the whole collection.
107 /// </summary> 83 /// </summary>
108 /// <returns>Untyped collection enumerator.</returns> 84 /// <returns>Untyped collection enumerator.</returns>
109 System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() 85 System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() => this.collection.Values.GetEnumerator();
110 {
111 return this.collection.Values.GetEnumerator();
112 }
113 86
114 /// <summary> 87 /// <summary>
115 /// Gets a table by name. 88 /// Gets a table by name.
@@ -117,16 +90,8 @@ namespace WixToolset.Data.WindowsInstaller
117 /// <param name="tableName">Name of table to locate.</param> 90 /// <param name="tableName">Name of table to locate.</param>
118 public Table this[string tableName] 91 public Table this[string tableName]
119 { 92 {
120 get 93 get => this.collection.TryGetValue(tableName, out var table) ? table : null;
121 { 94 set => this.collection[tableName] = value;
122 Table table;
123 return this.collection.TryGetValue(tableName, out table) ? table : null;
124 }
125
126 set
127 {
128 this.collection[tableName] = value;
129 }
130 } 95 }
131 96
132 /// <summary> 97 /// <summary>
@@ -135,9 +100,6 @@ namespace WixToolset.Data.WindowsInstaller
135 /// <param name="tableName">Table name to locate.</param> 100 /// <param name="tableName">Table name to locate.</param>
136 /// <param name="table">Found table.</param> 101 /// <param name="table">Found table.</param>
137 /// <returns>True if table with table name was found, otherwise false.</returns> 102 /// <returns>True if table with table name was found, otherwise false.</returns>
138 public bool TryGetTable(string tableName, out Table table) 103 public bool TryGetTable(string tableName, out Table table) => this.collection.TryGetValue(tableName, out table);
139 {
140 return this.collection.TryGetValue(tableName, out table);
141 }
142 } 104 }
143} 105}