diff options
| author | Rob Mensching <rob@firegiant.com> | 2017-12-27 13:13:41 -0800 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2017-12-27 13:13:41 -0800 |
| commit | b2ff456469c4905be6df44f851cbf42bbcd629ee (patch) | |
| tree | e196a0ff99ee130e517f1fa9f6281163dd4a77b8 /src | |
| parent | 9c44ebe3f4e47d22cf9b74918ac30e8bf36ffe5b (diff) | |
| download | wix-b2ff456469c4905be6df44f851cbf42bbcd629ee.tar.gz wix-b2ff456469c4905be6df44f851cbf42bbcd629ee.tar.bz2 wix-b2ff456469c4905be6df44f851cbf42bbcd629ee.zip | |
Make TableDefinitions ColumnDefinitions an array and other minor cleanup
Diffstat (limited to 'src')
| -rw-r--r-- | src/WixToolset.Data/Data/messages.xml | 5 | ||||
| -rw-r--r-- | src/WixToolset.Data/WindowsInstaller/Field.cs | 12 | ||||
| -rw-r--r-- | src/WixToolset.Data/WindowsInstaller/Pdb.cs | 8 | ||||
| -rw-r--r-- | src/WixToolset.Data/WindowsInstaller/Row.cs | 2 | ||||
| -rw-r--r-- | src/WixToolset.Data/WindowsInstaller/TableDefinition.cs | 31 | ||||
| -rw-r--r-- | src/WixToolset.Data/WindowsInstaller/TableIndexedCollection.cs | 2 |
6 files changed, 23 insertions, 37 deletions
diff --git a/src/WixToolset.Data/Data/messages.xml b/src/WixToolset.Data/Data/messages.xml index 3acb21ba..5f03fef5 100644 --- a/src/WixToolset.Data/Data/messages.xml +++ b/src/WixToolset.Data/Data/messages.xml | |||
| @@ -1,6 +1,11 @@ | |||
| 1 | <?xml version='1.0' encoding='utf-8'?> | 1 | <?xml version='1.0' encoding='utf-8'?> |
| 2 | <!-- 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 | <!-- 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. --> |
| 3 | 3 | ||
| 4 | <!-- | ||
| 5 | |||
| 6 | This file has been kept for easy reference until we are certain we don't want to localize error strings. | ||
| 7 | |||
| 8 | --> | ||
| 4 | 9 | ||
| 5 | <Messages Namespace="WixToolset" Resources="Data.Messages" xmlns="http://schemas.microsoft.com/genmsgs/2004/07/messages"> | 10 | <Messages Namespace="WixToolset" Resources="Data.Messages" xmlns="http://schemas.microsoft.com/genmsgs/2004/07/messages"> |
| 6 | <Class Name="WixErrors" ContainerName="WixErrorEventArgs" BaseContainerName="MessageEventArgs" Level="Error"> | 11 | <Class Name="WixErrors" ContainerName="WixErrorEventArgs" BaseContainerName="MessageEventArgs" Level="Error"> |
diff --git a/src/WixToolset.Data/WindowsInstaller/Field.cs b/src/WixToolset.Data/WindowsInstaller/Field.cs index 11cd2c33..aa359c64 100644 --- a/src/WixToolset.Data/WindowsInstaller/Field.cs +++ b/src/WixToolset.Data/WindowsInstaller/Field.cs | |||
| @@ -35,16 +35,8 @@ namespace WixToolset.Data.WindowsInstaller | |||
| 35 | /// <value>Data in the field.</value> | 35 | /// <value>Data in the field.</value> |
| 36 | public object Data | 36 | public object Data |
| 37 | { | 37 | { |
| 38 | get | 38 | get => this.data; |
| 39 | { | 39 | set => this.data = this.ValidateValue(this.Column, value); |
| 40 | return this.data; | ||
| 41 | } | ||
| 42 | |||
| 43 | set | ||
| 44 | { | ||
| 45 | // Validate the value before setting it. | ||
| 46 | this.data = this.ValidateValue(this.Column, value); | ||
| 47 | } | ||
| 48 | } | 40 | } |
| 49 | 41 | ||
| 50 | /// <summary> | 42 | /// <summary> |
diff --git a/src/WixToolset.Data/WindowsInstaller/Pdb.cs b/src/WixToolset.Data/WindowsInstaller/Pdb.cs index d3fea0fe..574d5593 100644 --- a/src/WixToolset.Data/WindowsInstaller/Pdb.cs +++ b/src/WixToolset.Data/WindowsInstaller/Pdb.cs | |||
| @@ -15,14 +15,6 @@ namespace WixToolset.Data.WindowsInstaller | |||
| 15 | private static readonly Version CurrentVersion = new Version("4.0.0.0"); | 15 | private static readonly Version CurrentVersion = new Version("4.0.0.0"); |
| 16 | 16 | ||
| 17 | /// <summary> | 17 | /// <summary> |
| 18 | /// Creates a new empty pdb object. | ||
| 19 | /// </summary> | ||
| 20 | /// <param name="sourceLineNumbers">The source line information for the pdb.</param> | ||
| 21 | public Pdb() | ||
| 22 | { | ||
| 23 | } | ||
| 24 | |||
| 25 | /// <summary> | ||
| 26 | /// Gets or sets the output that is a part of this pdb. | 18 | /// Gets or sets the output that is a part of this pdb. |
| 27 | /// </summary> | 19 | /// </summary> |
| 28 | /// <value>Type of the output.</value> | 20 | /// <value>Type of the output.</value> |
diff --git a/src/WixToolset.Data/WindowsInstaller/Row.cs b/src/WixToolset.Data/WindowsInstaller/Row.cs index cb8b81d8..af1af628 100644 --- a/src/WixToolset.Data/WindowsInstaller/Row.cs +++ b/src/WixToolset.Data/WindowsInstaller/Row.cs | |||
| @@ -37,7 +37,7 @@ namespace WixToolset.Data.WindowsInstaller | |||
| 37 | { | 37 | { |
| 38 | this.Number = rowCount++; | 38 | this.Number = rowCount++; |
| 39 | this.SourceLineNumbers = sourceLineNumbers; | 39 | this.SourceLineNumbers = sourceLineNumbers; |
| 40 | this.Fields = new Field[tableDefinition.Columns.Count]; | 40 | this.Fields = new Field[tableDefinition.Columns.Length]; |
| 41 | this.TableDefinition = tableDefinition; | 41 | this.TableDefinition = tableDefinition; |
| 42 | 42 | ||
| 43 | for (var i = 0; i < this.Fields.Length; ++i) | 43 | for (var i = 0; i < this.Fields.Length; ++i) |
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> |
diff --git a/src/WixToolset.Data/WindowsInstaller/TableIndexedCollection.cs b/src/WixToolset.Data/WindowsInstaller/TableIndexedCollection.cs index 1b7de72b..57ba19d1 100644 --- a/src/WixToolset.Data/WindowsInstaller/TableIndexedCollection.cs +++ b/src/WixToolset.Data/WindowsInstaller/TableIndexedCollection.cs | |||
| @@ -17,7 +17,7 @@ namespace WixToolset.Data.WindowsInstaller | |||
| 17 | /// </summary> | 17 | /// </summary> |
| 18 | public TableIndexedCollection() | 18 | public TableIndexedCollection() |
| 19 | { | 19 | { |
| 20 | this.collection = new Dictionary<string,Table>(); | 20 | this.collection = new Dictionary<string, Table>(); |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | /// <summary> | 23 | /// <summary> |
