From b2ff456469c4905be6df44f851cbf42bbcd629ee Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Wed, 27 Dec 2017 13:13:41 -0800 Subject: Make TableDefinitions ColumnDefinitions an array and other minor cleanup --- .../WindowsInstaller/TableDefinition.cs | 31 ++++++++++------------ 1 file changed, 14 insertions(+), 17 deletions(-) (limited to 'src/WixToolset.Data/WindowsInstaller/TableDefinition.cs') 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 /// Column definitions for the table. /// Flag if table is unreal. /// Flag if table is part of UX Manifest. - public TableDefinition(string name, IList columns, bool unreal = false, bool bootstrapperApplicationData = false) + public TableDefinition(string name, ColumnDefinition[] columns, bool unreal = false, bool bootstrapperApplicationData = false) { this.Name = name; this.Unreal = unreal; this.BootstrapperApplicationData = bootstrapperApplicationData; - this.Columns = new ReadOnlyCollection(columns); + this.Columns = columns; } /// @@ -56,17 +56,14 @@ namespace WixToolset.Data.WindowsInstaller /// Gets the collection of column definitions for this table. /// /// Collection of column definitions for this table. - public IList Columns { get; private set; } + public ColumnDefinition[] Columns { get; private set; } /// /// Gets the column definition in the table by index. /// /// Index of column to locate. /// Column definition in the table by index. - public ColumnDefinition this[int columnIndex] - { - get { return this.Columns[columnIndex]; } - } + public ColumnDefinition this[int columnIndex] => this.Columns[columnIndex]; /// /// Compares this table definition to another table definition. @@ -91,10 +88,10 @@ namespace WixToolset.Data.WindowsInstaller if (0 == ret) { // transforms can only add columns - ret = Math.Min(0, updated.Columns.Count - this.Columns.Count); + ret = Math.Min(0, updated.Columns.Length - this.Columns.Length); // compare name, type, and length of each column - for (int i = 0; 0 == ret && this.Columns.Count > i; i++) + for (int i = 0; 0 == ret && this.Columns.Length > i; i++) { ColumnDefinition thisColumnDef = this.Columns[i]; ColumnDefinition updatedColumnDef = updated.Columns[i]; @@ -113,10 +110,10 @@ namespace WixToolset.Data.WindowsInstaller /// The TableDefintion represented by the Xml. internal static TableDefinition Read(XmlReader reader) { - bool empty = reader.IsEmptyElement; + var empty = reader.IsEmptyElement; string name = null; - bool unreal = false; - bool bootstrapperApplicationData = false; + var unreal = false; + var bootstrapperApplicationData = false; while (reader.MoveToNextAttribute()) { @@ -139,13 +136,13 @@ namespace WixToolset.Data.WindowsInstaller throw new XmlException(); } - List columns = new List(); - bool hasPrimaryKeyColumn = false; + var columns = new List(); + var hasPrimaryKeyColumn = false; // parse the child elements if (!empty) { - bool done = false; + var done = false; while (!done && reader.Read()) { @@ -155,7 +152,7 @@ namespace WixToolset.Data.WindowsInstaller switch (reader.LocalName) { case "columnDefinition": - ColumnDefinition columnDefinition = ColumnDefinition.Read(reader); + var columnDefinition = ColumnDefinition.Read(reader); columns.Add(columnDefinition); if (columnDefinition.PrimaryKey) @@ -184,7 +181,7 @@ namespace WixToolset.Data.WindowsInstaller } } - return new TableDefinition(name, columns, unreal, bootstrapperApplicationData); + return new TableDefinition(name, columns.ToArray(), unreal, bootstrapperApplicationData); } /// -- cgit v1.2.3-55-g6feb