diff options
Diffstat (limited to 'src/WixToolset.Data/WindowsInstaller/TableDefinition.cs')
| -rw-r--r-- | src/WixToolset.Data/WindowsInstaller/TableDefinition.cs | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/src/WixToolset.Data/WindowsInstaller/TableDefinition.cs b/src/WixToolset.Data/WindowsInstaller/TableDefinition.cs index 2fb655e5..bc7fb537 100644 --- a/src/WixToolset.Data/WindowsInstaller/TableDefinition.cs +++ b/src/WixToolset.Data/WindowsInstaller/TableDefinition.cs | |||
| @@ -25,13 +25,13 @@ namespace WixToolset.Data.WindowsInstaller | |||
| 25 | /// <param name="columns">Column definitions for the table.</param> | 25 | /// <param name="columns">Column definitions for the table.</param> |
| 26 | /// <param name="unreal">Flag if table is unreal.</param> | 26 | /// <param name="unreal">Flag if table is unreal.</param> |
| 27 | /// <param name="bootstrapperApplicationData">Flag if table is part of UX Manifest.</param> | 27 | /// <param name="bootstrapperApplicationData">Flag if table is part of UX Manifest.</param> |
| 28 | public TableDefinition(string name, IList<ColumnDefinition> columns, bool unreal = false, bool bootstrapperApplicationData = false) | 28 | public TableDefinition(string name, ColumnDefinition[] columns, bool unreal = false, bool bootstrapperApplicationData = false) |
| 29 | { | 29 | { |
| 30 | this.Name = name; | 30 | this.Name = name; |
| 31 | this.Unreal = unreal; | 31 | this.Unreal = unreal; |
| 32 | this.BootstrapperApplicationData = bootstrapperApplicationData; | 32 | this.BootstrapperApplicationData = bootstrapperApplicationData; |
| 33 | 33 | ||
| 34 | this.Columns = new ReadOnlyCollection<ColumnDefinition>(columns); | 34 | this.Columns = columns; |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | /// <summary> | 37 | /// <summary> |
| @@ -56,17 +56,14 @@ namespace WixToolset.Data.WindowsInstaller | |||
| 56 | /// Gets the collection of column definitions for this table. | 56 | /// Gets the collection of column definitions for this table. |
| 57 | /// </summary> | 57 | /// </summary> |
| 58 | /// <value>Collection of column definitions for this table.</value> | 58 | /// <value>Collection of column definitions for this table.</value> |
| 59 | public IList<ColumnDefinition> Columns { get; private set; } | 59 | public ColumnDefinition[] Columns { get; private set; } |
| 60 | 60 | ||
| 61 | /// <summary> | 61 | /// <summary> |
| 62 | /// Gets the column definition in the table by index. | 62 | /// Gets the column definition in the table by index. |
| 63 | /// </summary> | 63 | /// </summary> |
| 64 | /// <param name="columnIndex">Index of column to locate.</param> | 64 | /// <param name="columnIndex">Index of column to locate.</param> |
| 65 | /// <value>Column definition in the table by index.</value> | 65 | /// <value>Column definition in the table by index.</value> |
| 66 | public ColumnDefinition this[int columnIndex] | 66 | public ColumnDefinition this[int columnIndex] => this.Columns[columnIndex]; |
| 67 | { | ||
| 68 | get { return this.Columns[columnIndex]; } | ||
| 69 | } | ||
| 70 | 67 | ||
| 71 | /// <summary> | 68 | /// <summary> |
| 72 | /// Compares this table definition to another table definition. | 69 | /// Compares this table definition to another table definition. |
| @@ -91,10 +88,10 @@ namespace WixToolset.Data.WindowsInstaller | |||
| 91 | if (0 == ret) | 88 | if (0 == ret) |
| 92 | { | 89 | { |
| 93 | // transforms can only add columns | 90 | // transforms can only add columns |
| 94 | ret = Math.Min(0, updated.Columns.Count - this.Columns.Count); | 91 | ret = Math.Min(0, updated.Columns.Length - this.Columns.Length); |
| 95 | 92 | ||
| 96 | // compare name, type, and length of each column | 93 | // compare name, type, and length of each column |
| 97 | for (int i = 0; 0 == ret && this.Columns.Count > i; i++) | 94 | for (int i = 0; 0 == ret && this.Columns.Length > i; i++) |
| 98 | { | 95 | { |
| 99 | ColumnDefinition thisColumnDef = this.Columns[i]; | 96 | ColumnDefinition thisColumnDef = this.Columns[i]; |
| 100 | ColumnDefinition updatedColumnDef = updated.Columns[i]; | 97 | ColumnDefinition updatedColumnDef = updated.Columns[i]; |
| @@ -113,10 +110,10 @@ namespace WixToolset.Data.WindowsInstaller | |||
| 113 | /// <returns>The TableDefintion represented by the Xml.</returns> | 110 | /// <returns>The TableDefintion represented by the Xml.</returns> |
| 114 | internal static TableDefinition Read(XmlReader reader) | 111 | internal static TableDefinition Read(XmlReader reader) |
| 115 | { | 112 | { |
| 116 | bool empty = reader.IsEmptyElement; | 113 | var empty = reader.IsEmptyElement; |
| 117 | string name = null; | 114 | string name = null; |
| 118 | bool unreal = false; | 115 | var unreal = false; |
| 119 | bool bootstrapperApplicationData = false; | 116 | var bootstrapperApplicationData = false; |
| 120 | 117 | ||
| 121 | while (reader.MoveToNextAttribute()) | 118 | while (reader.MoveToNextAttribute()) |
| 122 | { | 119 | { |
| @@ -139,13 +136,13 @@ namespace WixToolset.Data.WindowsInstaller | |||
| 139 | throw new XmlException(); | 136 | throw new XmlException(); |
| 140 | } | 137 | } |
| 141 | 138 | ||
| 142 | List<ColumnDefinition> columns = new List<ColumnDefinition>(); | 139 | var columns = new List<ColumnDefinition>(); |
| 143 | bool hasPrimaryKeyColumn = false; | 140 | var hasPrimaryKeyColumn = false; |
| 144 | 141 | ||
| 145 | // parse the child elements | 142 | // parse the child elements |
| 146 | if (!empty) | 143 | if (!empty) |
| 147 | { | 144 | { |
| 148 | bool done = false; | 145 | var done = false; |
| 149 | 146 | ||
| 150 | while (!done && reader.Read()) | 147 | while (!done && reader.Read()) |
| 151 | { | 148 | { |
| @@ -155,7 +152,7 @@ namespace WixToolset.Data.WindowsInstaller | |||
| 155 | switch (reader.LocalName) | 152 | switch (reader.LocalName) |
| 156 | { | 153 | { |
| 157 | case "columnDefinition": | 154 | case "columnDefinition": |
| 158 | ColumnDefinition columnDefinition = ColumnDefinition.Read(reader); | 155 | var columnDefinition = ColumnDefinition.Read(reader); |
| 159 | columns.Add(columnDefinition); | 156 | columns.Add(columnDefinition); |
| 160 | 157 | ||
| 161 | if (columnDefinition.PrimaryKey) | 158 | if (columnDefinition.PrimaryKey) |
| @@ -184,7 +181,7 @@ namespace WixToolset.Data.WindowsInstaller | |||
| 184 | } | 181 | } |
| 185 | } | 182 | } |
| 186 | 183 | ||
| 187 | return new TableDefinition(name, columns, unreal, bootstrapperApplicationData); | 184 | return new TableDefinition(name, columns.ToArray(), unreal, bootstrapperApplicationData); |
| 188 | } | 185 | } |
| 189 | 186 | ||
| 190 | /// <summary> | 187 | /// <summary> |
