diff options
Diffstat (limited to 'src/WixToolset.Data/TableIndexedCollection.cs')
| -rw-r--r-- | src/WixToolset.Data/TableIndexedCollection.cs | 153 |
1 files changed, 0 insertions, 153 deletions
diff --git a/src/WixToolset.Data/TableIndexedCollection.cs b/src/WixToolset.Data/TableIndexedCollection.cs deleted file mode 100644 index 9f85efff..00000000 --- a/src/WixToolset.Data/TableIndexedCollection.cs +++ /dev/null | |||
| @@ -1,153 +0,0 @@ | |||
| 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
| 2 | |||
| 3 | namespace WixToolset.Data | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.Collections.Generic; | ||
| 7 | using System.Linq; | ||
| 8 | |||
| 9 | /// <summary> | ||
| 10 | /// Collection for tables. | ||
| 11 | /// </summary> | ||
| 12 | public sealed class TableIndexedCollection : ICollection<Table> | ||
| 13 | { | ||
| 14 | private Dictionary<string, Table> collection; | ||
| 15 | |||
| 16 | /// <summary> | ||
| 17 | /// Instantiate a new empty collection. | ||
| 18 | /// </summary> | ||
| 19 | public TableIndexedCollection() | ||
| 20 | { | ||
| 21 | this.collection = new Dictionary<string,Table>(); | ||
| 22 | } | ||
| 23 | |||
| 24 | /// <summary> | ||
| 25 | /// Instantiate a new collection populated with a set of tables. | ||
| 26 | /// </summary> | ||
| 27 | /// <param name="tables">Set of tables.</param> | ||
| 28 | public TableIndexedCollection(IEnumerable<Table> tables) | ||
| 29 | { | ||
| 30 | this.collection = tables.ToDictionary(t => t.Name); | ||
| 31 | } | ||
| 32 | |||
| 33 | /// <summary> | ||
| 34 | /// Gets the number of items in the collection. | ||
| 35 | /// </summary> | ||
| 36 | /// <value>Number of items in collection.</value> | ||
| 37 | public int Count | ||
| 38 | { | ||
| 39 | get { return this.collection.Count; } | ||
| 40 | } | ||
| 41 | |||
| 42 | /// <summary> | ||
| 43 | /// Table indexed collection is never read only. | ||
| 44 | /// </summary> | ||
| 45 | public bool IsReadOnly | ||
| 46 | { | ||
| 47 | get { return false; } | ||
| 48 | } | ||
| 49 | |||
| 50 | /// <summary> | ||
| 51 | /// Adds a table to the collection. | ||
| 52 | /// </summary> | ||
| 53 | /// <param name="table">Table to add to the collection.</param> | ||
| 54 | /// <remarks>Indexes the table by name.</remarks> | ||
| 55 | public void Add(Table table) | ||
| 56 | { | ||
| 57 | this.collection.Add(table.Name, table); | ||
| 58 | } | ||
| 59 | |||
| 60 | /// <summary> | ||
| 61 | /// Clear the tables from the collection. | ||
| 62 | /// </summary> | ||
| 63 | public void Clear() | ||
| 64 | { | ||
| 65 | this.collection.Clear(); | ||
| 66 | } | ||
| 67 | |||
| 68 | /// <summary> | ||
| 69 | /// Determines if a table is in the collection. | ||
| 70 | /// </summary> | ||
| 71 | /// <param name="table">Table to check if it is in the collection.</param> | ||
| 72 | /// <returns>True if the table name is in the collection, otherwise false.</returns> | ||
| 73 | public bool Contains(Table table) | ||
| 74 | { | ||
| 75 | return this.collection.ContainsKey(table.Name); | ||
| 76 | } | ||
| 77 | |||
| 78 | /// <summary> | ||
| 79 | /// Copies the collection into an array. | ||
| 80 | /// </summary> | ||
| 81 | /// <param name="array">Array to copy the collection into.</param> | ||
| 82 | /// <param name="arrayIndex">Index to start copying from.</param> | ||
| 83 | public void CopyTo(Table[] array, int arrayIndex) | ||
| 84 | { | ||
| 85 | this.collection.Values.CopyTo(array, arrayIndex); | ||
| 86 | } | ||
| 87 | |||
| 88 | /// <summary> | ||
| 89 | /// Remove a table from the collection by name. | ||
| 90 | /// </summary> | ||
| 91 | /// <param name="tableName">Table name to remove from the collection.</param> | ||
| 92 | public void Remove(string tableName) | ||
| 93 | { | ||
| 94 | this.collection.Remove(tableName); | ||
| 95 | } | ||
| 96 | |||
| 97 | /// <summary> | ||
| 98 | /// Remove a table from the collection. | ||
| 99 | /// </summary> | ||
| 100 | /// <param name="table">Table with matching name to remove from the collection.</param> | ||
| 101 | public bool Remove(Table table) | ||
| 102 | { | ||
| 103 | return this.collection.Remove(table.Name); | ||
| 104 | } | ||
| 105 | |||
| 106 | /// <summary> | ||
| 107 | /// Gets an enumerator over the whole collection. | ||
| 108 | /// </summary> | ||
| 109 | /// <returns>Collection enumerator.</returns> | ||
| 110 | public IEnumerator<Table> GetEnumerator() | ||
| 111 | { | ||
| 112 | return this.collection.Values.GetEnumerator(); | ||
| 113 | } | ||
| 114 | |||
| 115 | /// <summary> | ||
| 116 | /// Gets an untyped enumerator over the whole collection. | ||
| 117 | /// </summary> | ||
| 118 | /// <returns>Untyped collection enumerator.</returns> | ||
| 119 | System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() | ||
| 120 | { | ||
| 121 | return this.collection.Values.GetEnumerator(); | ||
| 122 | } | ||
| 123 | |||
| 124 | /// <summary> | ||
| 125 | /// Gets a table by name. | ||
| 126 | /// </summary> | ||
| 127 | /// <param name="tableName">Name of table to locate.</param> | ||
| 128 | public Table this[string tableName] | ||
| 129 | { | ||
| 130 | get | ||
| 131 | { | ||
| 132 | Table table; | ||
| 133 | return this.collection.TryGetValue(tableName, out table) ? table : null; | ||
| 134 | } | ||
| 135 | |||
| 136 | set | ||
| 137 | { | ||
| 138 | this.collection[tableName] = value; | ||
| 139 | } | ||
| 140 | } | ||
| 141 | |||
| 142 | /// <summary> | ||
| 143 | /// Tries to find a table by name. | ||
| 144 | /// </summary> | ||
| 145 | /// <param name="tableName">Table name to locate.</param> | ||
| 146 | /// <param name="table">Found table.</param> | ||
| 147 | /// <returns>True if table with table name was found, otherwise false.</returns> | ||
| 148 | public bool TryGetTable(string tableName, out Table table) | ||
| 149 | { | ||
| 150 | return this.collection.TryGetValue(tableName, out table); | ||
| 151 | } | ||
| 152 | } | ||
| 153 | } | ||
