diff options
| author | Rob Mensching <rob@firegiant.com> | 2020-02-05 14:36:35 -0800 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2020-02-05 14:43:36 -0800 |
| commit | df8f367c7bc515be7f5652338f1e64e6a9e6acd8 (patch) | |
| tree | 3092126d5304e8881b58556fb77fbf1b9b9e237d /src | |
| parent | e87c38acec6597ab4d98820e2ba1fc891483c023 (diff) | |
| download | wix-df8f367c7bc515be7f5652338f1e64e6a9e6acd8.tar.gz wix-df8f367c7bc515be7f5652338f1e64e6a9e6acd8.tar.bz2 wix-df8f367c7bc515be7f5652338f1e64e6a9e6acd8.zip | |
Code cleanup
Diffstat (limited to 'src')
5 files changed, 117 insertions, 606 deletions
diff --git a/src/WixToolset.Data/WindowsInstaller/Rows/FileRow.cs b/src/WixToolset.Data/WindowsInstaller/Rows/FileRow.cs index cd3660e4..1cf8cf12 100644 --- a/src/WixToolset.Data/WindowsInstaller/Rows/FileRow.cs +++ b/src/WixToolset.Data/WindowsInstaller/Rows/FileRow.cs | |||
| @@ -2,41 +2,13 @@ | |||
| 2 | 2 | ||
| 3 | namespace WixToolset.Data.WindowsInstaller.Rows | 3 | namespace WixToolset.Data.WindowsInstaller.Rows |
| 4 | { | 4 | { |
| 5 | using System; | ||
| 6 | using System.Diagnostics; | 5 | using System.Diagnostics; |
| 7 | using System.Globalization; | ||
| 8 | 6 | ||
| 9 | /// <summary> | 7 | /// <summary> |
| 10 | /// Specialization of a row for the file table. | 8 | /// Specialization of a row for the file table. |
| 11 | /// </summary> | 9 | /// </summary> |
| 12 | public sealed class FileRow : Row //, IComparable | 10 | public sealed class FileRow : Row |
| 13 | { | 11 | { |
| 14 | //private string assemblyApplication; | ||
| 15 | //private string assemblyManifest; | ||
| 16 | //private FileAssemblyType assemblyType; | ||
| 17 | //private string directory; | ||
| 18 | //private int diskId; | ||
| 19 | //private bool fromModule; | ||
| 20 | //private bool isGeneratedShortFileName; | ||
| 21 | //private int patchGroup; | ||
| 22 | //private string processorArchitecture; | ||
| 23 | //private string source; | ||
| 24 | //private Row hashRow; | ||
| 25 | //private List<Row> assemblyNameRows; | ||
| 26 | //private string[] previousSource; | ||
| 27 | //private string symbols; | ||
| 28 | //private string[] previousSymbols; | ||
| 29 | //private PatchAttributeType patchAttributes; | ||
| 30 | //private string retainOffsets; | ||
| 31 | //private string retainLengths; | ||
| 32 | //private string ignoreOffsets; | ||
| 33 | //private string ignoreLengths; | ||
| 34 | //private string[] previousRetainOffsets; | ||
| 35 | //private string[] previousRetainLengths; | ||
| 36 | //private string[] previousIgnoreOffsets; | ||
| 37 | //private string[] previousIgnoreLengths; | ||
| 38 | //private string patch; | ||
| 39 | |||
| 40 | /// <summary> | 12 | /// <summary> |
| 41 | /// Creates a File row that belongs to a table. | 13 | /// Creates a File row that belongs to a table. |
| 42 | /// </summary> | 14 | /// </summary> |
| @@ -45,13 +17,6 @@ namespace WixToolset.Data.WindowsInstaller.Rows | |||
| 45 | public FileRow(SourceLineNumber sourceLineNumbers, Table table) | 17 | public FileRow(SourceLineNumber sourceLineNumbers, Table table) |
| 46 | : base(sourceLineNumbers, table) | 18 | : base(sourceLineNumbers, table) |
| 47 | { | 19 | { |
| 48 | //this.assemblyType = FileAssemblyType.NotAnAssembly; | ||
| 49 | //this.previousSource = new string[1]; | ||
| 50 | //this.previousSymbols = new string[1]; | ||
| 51 | //this.previousRetainOffsets = new string[1]; | ||
| 52 | //this.previousRetainLengths = new string[1]; | ||
| 53 | //this.previousIgnoreOffsets = new string[1]; | ||
| 54 | //this.previousIgnoreLengths = new string[1]; | ||
| 55 | } | 20 | } |
| 56 | 21 | ||
| 57 | /// <summary> | 22 | /// <summary> |
| @@ -62,13 +27,6 @@ namespace WixToolset.Data.WindowsInstaller.Rows | |||
| 62 | public FileRow(SourceLineNumber sourceLineNumbers, TableDefinition tableDefinition) | 27 | public FileRow(SourceLineNumber sourceLineNumbers, TableDefinition tableDefinition) |
| 63 | : base(sourceLineNumbers, tableDefinition) | 28 | : base(sourceLineNumbers, tableDefinition) |
| 64 | { | 29 | { |
| 65 | //this.assemblyType = FileAssemblyType.NotAnAssembly; | ||
| 66 | //this.previousSource = new string[1]; | ||
| 67 | //this.previousSymbols = new string[1]; | ||
| 68 | //this.previousRetainOffsets = new string[1]; | ||
| 69 | //this.previousRetainLengths = new string[1]; | ||
| 70 | //this.previousIgnoreOffsets = new string[1]; | ||
| 71 | //this.previousIgnoreLengths = new string[1]; | ||
| 72 | } | 30 | } |
| 73 | 31 | ||
| 74 | /// <summary> | 32 | /// <summary> |
| @@ -77,8 +35,8 @@ namespace WixToolset.Data.WindowsInstaller.Rows | |||
| 77 | /// <value>Primary key of the file row.</value> | 35 | /// <value>Primary key of the file row.</value> |
| 78 | public string File | 36 | public string File |
| 79 | { | 37 | { |
| 80 | get { return (string)this.Fields[0].Data; } | 38 | get => this.FieldAsString(0); |
| 81 | set { this.Fields[0].Data = value; } | 39 | set => this.Fields[0].Data = value; |
| 82 | } | 40 | } |
| 83 | 41 | ||
| 84 | /// <summary> | 42 | /// <summary> |
| @@ -87,8 +45,8 @@ namespace WixToolset.Data.WindowsInstaller.Rows | |||
| 87 | /// <value>Component this file row belongs to.</value> | 45 | /// <value>Component this file row belongs to.</value> |
| 88 | public string Component | 46 | public string Component |
| 89 | { | 47 | { |
| 90 | get { return (string)this.Fields[1].Data; } | 48 | get => this.FieldAsString(1); |
| 91 | set { this.Fields[1].Data = value; } | 49 | set => this.Fields[1].Data = value; |
| 92 | } | 50 | } |
| 93 | 51 | ||
| 94 | /// <summary> | 52 | /// <summary> |
| @@ -97,8 +55,8 @@ namespace WixToolset.Data.WindowsInstaller.Rows | |||
| 97 | /// <value>Name of the file.</value> | 55 | /// <value>Name of the file.</value> |
| 98 | public string FileName | 56 | public string FileName |
| 99 | { | 57 | { |
| 100 | get { return (string)this.Fields[2].Data; } | 58 | get => this.FieldAsString(2); |
| 101 | set { this.Fields[2].Data = value; } | 59 | set => this.Fields[2].Data = value; |
| 102 | } | 60 | } |
| 103 | 61 | ||
| 104 | /// <summary> | 62 | /// <summary> |
| @@ -110,18 +68,12 @@ namespace WixToolset.Data.WindowsInstaller.Rows | |||
| 110 | { | 68 | { |
| 111 | get | 69 | get |
| 112 | { | 70 | { |
| 113 | string fileName = this.FileName; | 71 | var fileName = this.FileName; |
| 114 | int index = fileName.IndexOf('|'); | 72 | var index = fileName.IndexOf('|'); |
| 115 | 73 | ||
| 116 | // If it doesn't contain a pipe, just return the whole string | 74 | // If it doesn't contain a pipe, just return the whole string |
| 117 | if (-1 == index) | 75 | // otherwise, extract the part of the string after the pipe. |
| 118 | { | 76 | return (-1 == index) ? fileName : fileName.Substring(index + 1); |
| 119 | return fileName; | ||
| 120 | } | ||
| 121 | else // otherwise, extract the part of the string after the pipe | ||
| 122 | { | ||
| 123 | return fileName.Substring(index + 1); | ||
| 124 | } | ||
| 125 | } | 77 | } |
| 126 | } | 78 | } |
| 127 | 79 | ||
| @@ -131,8 +83,8 @@ namespace WixToolset.Data.WindowsInstaller.Rows | |||
| 131 | /// <value>Size of the file.</value> | 83 | /// <value>Size of the file.</value> |
| 132 | public int FileSize | 84 | public int FileSize |
| 133 | { | 85 | { |
| 134 | get { return (int)this.Fields[3].Data; } | 86 | get => this.FieldAsInteger(3); |
| 135 | set { this.Fields[3].Data = value; } | 87 | set => this.Fields[3].Data = value; |
| 136 | } | 88 | } |
| 137 | 89 | ||
| 138 | /// <summary> | 90 | /// <summary> |
| @@ -141,8 +93,8 @@ namespace WixToolset.Data.WindowsInstaller.Rows | |||
| 141 | /// <value>Version of the file.</value> | 93 | /// <value>Version of the file.</value> |
| 142 | public string Version | 94 | public string Version |
| 143 | { | 95 | { |
| 144 | get { return (string)this.Fields[4].Data; } | 96 | get => this.FieldAsString(4); |
| 145 | set { this.Fields[4].Data = value; } | 97 | set => this.Fields[4].Data = value; |
| 146 | } | 98 | } |
| 147 | 99 | ||
| 148 | /// <summary> | 100 | /// <summary> |
| @@ -151,8 +103,8 @@ namespace WixToolset.Data.WindowsInstaller.Rows | |||
| 151 | /// <value>LCID of the file.</value> | 103 | /// <value>LCID of the file.</value> |
| 152 | public string Language | 104 | public string Language |
| 153 | { | 105 | { |
| 154 | get { return (string)this.Fields[5].Data; } | 106 | get => this.FieldAsString(5); |
| 155 | set { this.Fields[5].Data = value; } | 107 | set => this.Fields[5].Data = value; |
| 156 | } | 108 | } |
| 157 | 109 | ||
| 158 | /// <summary> | 110 | /// <summary> |
| @@ -161,8 +113,8 @@ namespace WixToolset.Data.WindowsInstaller.Rows | |||
| 161 | /// <value>Attributes on a file.</value> | 113 | /// <value>Attributes on a file.</value> |
| 162 | public int Attributes | 114 | public int Attributes |
| 163 | { | 115 | { |
| 164 | get { return Convert.ToInt32(this.Fields[6].Data, CultureInfo.InvariantCulture); } | 116 | get => this.FieldAsInteger(6); |
| 165 | set { this.Fields[6].Data = value; } | 117 | set => this.Fields[6].Data = value; |
| 166 | } | 118 | } |
| 167 | 119 | ||
| 168 | /// <summary> | 120 | /// <summary> |
| @@ -173,8 +125,8 @@ namespace WixToolset.Data.WindowsInstaller.Rows | |||
| 173 | { | 125 | { |
| 174 | get | 126 | get |
| 175 | { | 127 | { |
| 176 | bool compressedFlag = (0 < (this.Attributes & WindowsInstallerConstants.MsidbFileAttributesCompressed)); | 128 | var compressedFlag = (0 < (this.Attributes & WindowsInstallerConstants.MsidbFileAttributesCompressed)); |
| 177 | bool noncompressedFlag = (0 < (this.Attributes & WindowsInstallerConstants.MsidbFileAttributesNoncompressed)); | 129 | var noncompressedFlag = (0 < (this.Attributes & WindowsInstallerConstants.MsidbFileAttributesNoncompressed)); |
| 178 | 130 | ||
| 179 | if (compressedFlag && noncompressedFlag) | 131 | if (compressedFlag && noncompressedFlag) |
| 180 | { | 132 | { |
| @@ -225,415 +177,38 @@ namespace WixToolset.Data.WindowsInstaller.Rows | |||
| 225 | /// <value>Sequence of the file row.</value> | 177 | /// <value>Sequence of the file row.</value> |
| 226 | public int Sequence | 178 | public int Sequence |
| 227 | { | 179 | { |
| 228 | get { return (int)this.Fields[7].Data; } | 180 | get => this.FieldAsInteger(7); |
| 229 | set { this.Fields[7].Data = value; } | 181 | set => this.Fields[7].Data = value; |
| 230 | } | 182 | } |
| 231 | 183 | ||
| 232 | /////// <summary> | 184 | /// <summary> |
| 233 | /////// Gets or sets the type of assembly of file row. | 185 | /// Gets or sets the disk id for this file. |
| 234 | /////// </summary> | 186 | /// </summary> |
| 235 | /////// <value>Assembly type for file row.</value> | 187 | /// <value>Disk id for the file.</value> |
| 236 | ////public FileAssemblyType AssemblyType | 188 | public int DiskId |
| 237 | ////{ | 189 | { |
| 238 | //// get { return this.assemblyType; } | 190 | get => this.FieldAsInteger(8); |
| 239 | //// set { this.assemblyType = value; } | 191 | set => this.Fields[8].Data = value; |
| 240 | ////} | 192 | } |
| 241 | |||
| 242 | /////// <summary> | ||
| 243 | /////// Gets or sets the identifier for the assembly application. | ||
| 244 | /////// </summary> | ||
| 245 | /////// <value>Identifier for the assembly application.</value> | ||
| 246 | ////public string AssemblyApplication | ||
| 247 | ////{ | ||
| 248 | //// get { return this.assemblyApplication; } | ||
| 249 | //// set { this.assemblyApplication = value; } | ||
| 250 | ////} | ||
| 251 | |||
| 252 | /////// <summary> | ||
| 253 | /////// Gets or sets the identifier for the assembly manifest. | ||
| 254 | /////// </summary> | ||
| 255 | /////// <value>Identifier for the assembly manifest.</value> | ||
| 256 | ////public string AssemblyManifest | ||
| 257 | ////{ | ||
| 258 | //// get { return this.assemblyManifest; } | ||
| 259 | //// set { this.assemblyManifest = value; } | ||
| 260 | ////} | ||
| 261 | |||
| 262 | /////// <summary> | ||
| 263 | /////// Gets or sets the directory of the file. | ||
| 264 | /////// </summary> | ||
| 265 | /////// <value>Directory of the file.</value> | ||
| 266 | ////public string Directory | ||
| 267 | ////{ | ||
| 268 | //// get { return this.directory; } | ||
| 269 | //// set { this.directory = value; } | ||
| 270 | ////} | ||
| 271 | |||
| 272 | /////// <summary> | ||
| 273 | /////// Gets or sets the disk id for this file. | ||
| 274 | /////// </summary> | ||
| 275 | /////// <value>Disk id for the file.</value> | ||
| 276 | ////public int DiskId | ||
| 277 | ////{ | ||
| 278 | //// get { return this.diskId; } | ||
| 279 | //// set { this.diskId = value; } | ||
| 280 | ////} | ||
| 281 | |||
| 282 | /////// <summary> | ||
| 283 | /////// Gets or sets the source location to the file. | ||
| 284 | /////// </summary> | ||
| 285 | /////// <value>Source location to the file.</value> | ||
| 286 | ////public string Source | ||
| 287 | ////{ | ||
| 288 | //// get { return this.source; } | ||
| 289 | //// set { this.source = value; } | ||
| 290 | ////} | ||
| 291 | |||
| 292 | /////// <summary> | ||
| 293 | /////// Gets or sets the source location to the previous file. | ||
| 294 | /////// </summary> | ||
| 295 | /////// <value>Source location to the previous file.</value> | ||
| 296 | ////public string PreviousSource | ||
| 297 | ////{ | ||
| 298 | //// get { return this.previousSource[0]; } | ||
| 299 | //// set { this.previousSource[0] = value; } | ||
| 300 | ////} | ||
| 301 | |||
| 302 | /////// <summary> | ||
| 303 | /////// Gets the source location to the previous files. | ||
| 304 | /////// </summary> | ||
| 305 | /////// <value>Source location to the previous files.</value> | ||
| 306 | ////[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] | ||
| 307 | ////public string[] PreviousSourceArray | ||
| 308 | ////{ | ||
| 309 | //// get { return this.previousSource; } | ||
| 310 | ////} | ||
| 311 | |||
| 312 | /////// <summary> | ||
| 313 | /////// Gets or sets the architecture the file executes on. | ||
| 314 | /////// </summary> | ||
| 315 | /////// <value>Architecture the file executes on.</value> | ||
| 316 | ////public string ProcessorArchitecture | ||
| 317 | ////{ | ||
| 318 | //// get { return this.processorArchitecture; } | ||
| 319 | //// set { this.processorArchitecture = value; } | ||
| 320 | ////} | ||
| 321 | |||
| 322 | /////// <summary> | ||
| 323 | /////// Gets of sets the patch group of a patch-added file. | ||
| 324 | /////// </summary> | ||
| 325 | /////// <value>The patch group of a patch-added file.</value> | ||
| 326 | ////public int PatchGroup | ||
| 327 | ////{ | ||
| 328 | //// get { return this.patchGroup; } | ||
| 329 | //// set { this.patchGroup = value; } | ||
| 330 | ////} | ||
| 331 | |||
| 332 | /////// <summary> | ||
| 333 | /////// Gets or sets the patch header of the file. | ||
| 334 | /////// </summary> | ||
| 335 | /////// <value>Patch header of the file.</value> | ||
| 336 | ////public string Patch | ||
| 337 | ////{ | ||
| 338 | //// get { return this.patch; } | ||
| 339 | //// set { this.patch = value; } | ||
| 340 | ////} | ||
| 341 | |||
| 342 | /////// <summary> | ||
| 343 | /////// Gets or sets the locations to find the file's symbols. | ||
| 344 | /////// </summary> | ||
| 345 | /////// <value>Symbol paths for the file.</value> | ||
| 346 | ////public string Symbols | ||
| 347 | ////{ | ||
| 348 | //// get { return this.symbols; } | ||
| 349 | //// set { this.symbols = value; } | ||
| 350 | ////} | ||
| 351 | |||
| 352 | /////// <summary> | ||
| 353 | /////// Gets or sets the locations to find the file's previous symbols. | ||
| 354 | /////// </summary> | ||
| 355 | /////// <value>Symbol paths for the previous file.</value> | ||
| 356 | ////public string PreviousSymbols | ||
| 357 | ////{ | ||
| 358 | //// get { return this.previousSymbols[0]; } | ||
| 359 | //// set { this.previousSymbols[0] = value; } | ||
| 360 | ////} | ||
| 361 | |||
| 362 | /////// <summary> | ||
| 363 | /////// Gets the locations to find the files' previous symbols. | ||
| 364 | /////// </summary> | ||
| 365 | /////// <value>Symbol paths for the previous files.</value> | ||
| 366 | ////[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] | ||
| 367 | ////public string[] PreviousSymbolsArray | ||
| 368 | ////{ | ||
| 369 | //// get { return this.previousSymbols; } | ||
| 370 | ////} | ||
| 371 | |||
| 372 | /////// <summary> | ||
| 373 | /////// Gets or sets the generated short file name attribute. | ||
| 374 | /////// </summary> | ||
| 375 | /////// <value>The generated short file name attribute.</value> | ||
| 376 | ////public bool IsGeneratedShortFileName | ||
| 377 | ////{ | ||
| 378 | //// get { return this.isGeneratedShortFileName; } | ||
| 379 | |||
| 380 | //// set { this.isGeneratedShortFileName = value; } | ||
| 381 | ////} | ||
| 382 | |||
| 383 | /////// <summary> | ||
| 384 | /////// Gets or sets whether this row came from a merge module. | ||
| 385 | /////// </summary> | ||
| 386 | /////// <value>Whether this row came from a merge module.</value> | ||
| 387 | ////public bool FromModule | ||
| 388 | ////{ | ||
| 389 | //// get { return this.fromModule; } | ||
| 390 | //// set { this.fromModule = value; } | ||
| 391 | ////} | ||
| 392 | |||
| 393 | /////// <summary> | ||
| 394 | /////// Gets or sets the MsiFileHash row created for this FileRow. | ||
| 395 | /////// </summary> | ||
| 396 | /////// <value>Row for MsiFileHash table.</value> | ||
| 397 | ////public Row HashRow | ||
| 398 | ////{ | ||
| 399 | //// get { return this.hashRow; } | ||
| 400 | //// set { this.hashRow = value; } | ||
| 401 | ////} | ||
| 402 | |||
| 403 | /////// <summary> | ||
| 404 | /////// Gets or sets the set of MsiAssemblyName rows created for this FileRow. | ||
| 405 | /////// </summary> | ||
| 406 | /////// <value>RowCollection of MsiAssemblyName table.</value> | ||
| 407 | ////[SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] | ||
| 408 | ////public List<Row> AssemblyNameRows | ||
| 409 | ////{ | ||
| 410 | //// get { return this.assemblyNameRows; } | ||
| 411 | //// set { this.assemblyNameRows = value; } | ||
| 412 | ////} | ||
| 413 | |||
| 414 | /////// <summary> | ||
| 415 | /////// Gets or sets the patching attributes to the file. | ||
| 416 | /////// </summary> | ||
| 417 | /////// <value>Patching attributes of the file.</value> | ||
| 418 | ////public PatchAttributeType PatchAttributes | ||
| 419 | ////{ | ||
| 420 | //// get { return this.patchAttributes; } | ||
| 421 | //// set { this.patchAttributes = value; } | ||
| 422 | ////} | ||
| 423 | |||
| 424 | /////// <summary> | ||
| 425 | /////// Gets or sets the delta patch retain-length list for the file. | ||
| 426 | /////// </summary> | ||
| 427 | /////// <value>RetainLength list for the file.</value> | ||
| 428 | ////public string RetainLengths | ||
| 429 | ////{ | ||
| 430 | //// get { return this.retainLengths; } | ||
| 431 | //// set { this.retainLengths = value; } | ||
| 432 | ////} | ||
| 433 | |||
| 434 | /////// <summary> | ||
| 435 | /////// Gets or sets the delta patch ignore-offset list for the file. | ||
| 436 | /////// </summary> | ||
| 437 | /////// <value>IgnoreOffset list for the file.</value> | ||
| 438 | ////public string IgnoreOffsets | ||
| 439 | ////{ | ||
| 440 | //// get { return this.ignoreOffsets; } | ||
| 441 | //// set { this.ignoreOffsets = value; } | ||
| 442 | ////} | ||
| 443 | |||
| 444 | /////// <summary> | ||
| 445 | /////// Gets or sets the delta patch ignore-length list for the file. | ||
| 446 | /////// </summary> | ||
| 447 | /////// <value>IgnoreLength list for the file.</value> | ||
| 448 | ////public string IgnoreLengths | ||
| 449 | ////{ | ||
| 450 | //// get { return this.ignoreLengths; } | ||
| 451 | //// set { this.ignoreLengths = value; } | ||
| 452 | ////} | ||
| 453 | |||
| 454 | /////// <summary> | ||
| 455 | /////// Gets or sets the delta patch retain-offset list for the file. | ||
| 456 | /////// </summary> | ||
| 457 | /////// <value>RetainOffset list for the file.</value> | ||
| 458 | ////public string RetainOffsets | ||
| 459 | ////{ | ||
| 460 | //// get { return this.retainOffsets; } | ||
| 461 | //// set { this.retainOffsets = value; } | ||
| 462 | ////} | ||
| 463 | |||
| 464 | /////// <summary> | ||
| 465 | /////// Gets or sets the delta patch retain-length list for the previous file. | ||
| 466 | /////// </summary> | ||
| 467 | /////// <value>RetainLength list for the previous file.</value> | ||
| 468 | ////public string PreviousRetainLengths | ||
| 469 | ////{ | ||
| 470 | //// get { return this.previousRetainLengths[0]; } | ||
| 471 | //// set { this.previousRetainLengths[0] = value; } | ||
| 472 | ////} | ||
| 473 | |||
| 474 | /////// <summary> | ||
| 475 | /////// Gets the delta patch retain-length list for the previous files. | ||
| 476 | /////// </summary> | ||
| 477 | /////// <value>RetainLength list for the previous files.</value> | ||
| 478 | ////[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] | ||
| 479 | ////public string[] PreviousRetainLengthsArray | ||
| 480 | ////{ | ||
| 481 | //// get { return this.previousRetainLengths; } | ||
| 482 | ////} | ||
| 483 | |||
| 484 | /////// <summary> | ||
| 485 | /////// Gets or sets the delta patch ignore-offset list for the previous file. | ||
| 486 | /////// </summary> | ||
| 487 | /////// <value>IgnoreOffset list for the previous file.</value> | ||
| 488 | ////public string PreviousIgnoreOffsets | ||
| 489 | ////{ | ||
| 490 | //// get { return this.previousIgnoreOffsets[0]; } | ||
| 491 | //// set { this.previousIgnoreOffsets[0] = value; } | ||
| 492 | ////} | ||
| 493 | |||
| 494 | /////// <summary> | ||
| 495 | /////// Gets the delta patch ignore-offset list for the previous files. | ||
| 496 | /////// </summary> | ||
| 497 | /////// <value>IgnoreOffset list for the previous files.</value> | ||
| 498 | ////[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] | ||
| 499 | ////public string[] PreviousIgnoreOffsetsArray | ||
| 500 | ////{ | ||
| 501 | //// get { return this.previousIgnoreOffsets; } | ||
| 502 | ////} | ||
| 503 | |||
| 504 | /////// <summary> | ||
| 505 | /////// Gets or sets the delta patch ignore-length list for the previous file. | ||
| 506 | /////// </summary> | ||
| 507 | /////// <value>IgnoreLength list for the previous file.</value> | ||
| 508 | ////public string PreviousIgnoreLengths | ||
| 509 | ////{ | ||
| 510 | //// get { return this.previousIgnoreLengths[0]; } | ||
| 511 | //// set { this.previousIgnoreLengths[0] = value; } | ||
| 512 | ////} | ||
| 513 | |||
| 514 | /////// <summary> | ||
| 515 | /////// Gets the delta patch ignore-length list for the previous files. | ||
| 516 | /////// </summary> | ||
| 517 | /////// <value>IgnoreLength list for the previous files.</value> | ||
| 518 | ////[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] | ||
| 519 | ////public string[] PreviousIgnoreLengthsArray | ||
| 520 | ////{ | ||
| 521 | //// get { return this.previousIgnoreLengths; } | ||
| 522 | ////} | ||
| 523 | |||
| 524 | /////// <summary> | ||
| 525 | /////// Gets or sets the delta patch retain-offset list for the previous file. | ||
| 526 | /////// </summary> | ||
| 527 | /////// <value>RetainOffset list for the previous file.</value> | ||
| 528 | ////public string PreviousRetainOffsets | ||
| 529 | ////{ | ||
| 530 | //// get { return this.previousRetainOffsets[0]; } | ||
| 531 | //// set { this.previousRetainOffsets[0] = value; } | ||
| 532 | ////} | ||
| 533 | |||
| 534 | /////// <summary> | ||
| 535 | /////// Gets the delta patch retain-offset list for the previous files. | ||
| 536 | /////// </summary> | ||
| 537 | /////// <value>RetainOffset list for the previous files.</value> | ||
| 538 | ////[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] | ||
| 539 | ////public string[] PreviousRetainOffsetsArray | ||
| 540 | ////{ | ||
| 541 | //// get { return this.previousRetainOffsets; } | ||
| 542 | ////} | ||
| 543 | |||
| 544 | /////// <summary> | ||
| 545 | /////// Compares the current FileRow with another object of the same type. | ||
| 546 | /////// </summary> | ||
| 547 | /////// <param name="obj">An object to compare with this instance.</param> | ||
| 548 | /////// <returns>An integer that indicates the relative order of the comparands.</returns> | ||
| 549 | ////[SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters", MessageId = "System.ArgumentException.#ctor(System.String)")] | ||
| 550 | ////[SuppressMessage("Microsoft.Globalization", "CA1309:UseOrdinalStringComparison")] | ||
| 551 | ////public int CompareTo(object obj) | ||
| 552 | ////{ | ||
| 553 | //// if (this == obj) | ||
| 554 | //// { | ||
| 555 | //// return 0; | ||
| 556 | //// } | ||
| 557 | |||
| 558 | //// FileRow fileRow = obj as FileRow; | ||
| 559 | //// if (null == fileRow) | ||
| 560 | //// { | ||
| 561 | //// throw new ArgumentException(WixDataStrings.EXP_OtherObjectIsNotFileRow); | ||
| 562 | //// } | ||
| 563 | |||
| 564 | //// int compared = this.DiskId - fileRow.DiskId; | ||
| 565 | //// if (0 == compared) | ||
| 566 | //// { | ||
| 567 | //// compared = this.patchGroup - fileRow.patchGroup; | ||
| 568 | |||
| 569 | //// if (0 == compared) | ||
| 570 | //// { | ||
| 571 | //// compared = String.Compare(this.File, fileRow.File, StringComparison.InvariantCulture); | ||
| 572 | //// } | ||
| 573 | //// } | ||
| 574 | |||
| 575 | //// return compared; | ||
| 576 | ////} | ||
| 577 | |||
| 578 | /////// <summary> | ||
| 579 | /////// Copies data from another FileRow object. | ||
| 580 | /////// </summary> | ||
| 581 | /////// <param name="src">An row to get data from.</param> | ||
| 582 | ////public void CopyFrom(FileRow src) | ||
| 583 | ////{ | ||
| 584 | //// for (int i = 0; i < src.Fields.Length; i++) | ||
| 585 | //// { | ||
| 586 | //// this[i] = src[i]; | ||
| 587 | //// } | ||
| 588 | //// this.assemblyManifest = src.assemblyManifest; | ||
| 589 | //// this.assemblyType = src.assemblyType; | ||
| 590 | //// this.directory = src.directory; | ||
| 591 | //// this.diskId = src.diskId; | ||
| 592 | //// this.fromModule = src.fromModule; | ||
| 593 | //// this.isGeneratedShortFileName = src.isGeneratedShortFileName; | ||
| 594 | //// this.patchGroup = src.patchGroup; | ||
| 595 | //// this.processorArchitecture = src.processorArchitecture; | ||
| 596 | //// this.source = src.source; | ||
| 597 | //// this.PreviousSource = src.PreviousSource; | ||
| 598 | //// this.Operation = src.Operation; | ||
| 599 | //// this.symbols = src.symbols; | ||
| 600 | //// this.PreviousSymbols = src.PreviousSymbols; | ||
| 601 | //// this.patchAttributes = src.patchAttributes; | ||
| 602 | //// this.retainOffsets = src.retainOffsets; | ||
| 603 | //// this.retainLengths = src.retainLengths; | ||
| 604 | //// this.ignoreOffsets = src.ignoreOffsets; | ||
| 605 | //// this.ignoreLengths = src.ignoreLengths; | ||
| 606 | //// this.PreviousRetainOffsets = src.PreviousRetainOffsets; | ||
| 607 | //// this.PreviousRetainLengths = src.PreviousRetainLengths; | ||
| 608 | //// this.PreviousIgnoreOffsets = src.PreviousIgnoreOffsets; | ||
| 609 | //// this.PreviousIgnoreLengths = src.PreviousIgnoreLengths; | ||
| 610 | ////} | ||
| 611 | 193 | ||
| 612 | /////// <summary> | 194 | /// <summary> |
| 613 | /////// Appends previous data from another FileRow object. | 195 | /// Gets or sets the source location to the file. |
| 614 | /////// </summary> | 196 | /// </summary> |
| 615 | /////// <param name="src">An row to get data from.</param> | 197 | /// <value>Source location to the file.</value> |
| 616 | ////public void AppendPreviousDataFrom(FileRow src) | 198 | public string Source |
| 617 | ////{ | 199 | { |
| 618 | //// AppendStringToArray(ref this.previousSource, src.previousSource[0]); | 200 | get => this.FieldAsString(9); |
| 619 | //// AppendStringToArray(ref this.previousSymbols, src.previousSymbols[0]); | 201 | set => this.Fields[9].Data = value; |
| 620 | //// AppendStringToArray(ref this.previousRetainOffsets, src.previousRetainOffsets[0]); | 202 | } |
| 621 | //// AppendStringToArray(ref this.previousRetainLengths, src.previousRetainLengths[0]); | ||
| 622 | //// AppendStringToArray(ref this.previousIgnoreOffsets, src.previousIgnoreOffsets[0]); | ||
| 623 | //// AppendStringToArray(ref this.previousIgnoreLengths, src.previousIgnoreLengths[0]); | ||
| 624 | ////} | ||
| 625 | 203 | ||
| 626 | /////// <summary> | 204 | /// <summary> |
| 627 | /////// Helper method for AppendPreviousDataFrom. | 205 | /// Gets or sets the source location to the previous file. |
| 628 | /////// </summary> | 206 | /// </summary> |
| 629 | /////// <param name="source">Destination array.</param> | 207 | /// <value>Source location to the previous file.</value> |
| 630 | /////// <param name="destination">Source string.</param> | 208 | public string PreviousSource |
| 631 | ////private static void AppendStringToArray(ref string[] destination, string source) | 209 | { |
| 632 | ////{ | 210 | get => this.Fields[9].PreviousData; |
| 633 | //// string[] result = new string[destination.Length + 1]; | 211 | set => this.Fields[9].PreviousData = value; |
| 634 | //// destination.CopyTo(result, 0); | 212 | } |
| 635 | //// result[destination.Length] = source; | ||
| 636 | //// destination = result; | ||
| 637 | ////} | ||
| 638 | } | 213 | } |
| 639 | } | 214 | } |
diff --git a/src/WixToolset.Data/WindowsInstaller/SubStorage.cs b/src/WixToolset.Data/WindowsInstaller/SubStorage.cs index 6aae1dd8..e24839c0 100644 --- a/src/WixToolset.Data/WindowsInstaller/SubStorage.cs +++ b/src/WixToolset.Data/WindowsInstaller/SubStorage.cs | |||
| @@ -39,15 +39,16 @@ namespace WixToolset.Data.WindowsInstaller | |||
| 39 | /// <returns>New SubStorage object.</returns> | 39 | /// <returns>New SubStorage object.</returns> |
| 40 | internal static SubStorage Read(XmlReader reader) | 40 | internal static SubStorage Read(XmlReader reader) |
| 41 | { | 41 | { |
| 42 | if (!reader.LocalName.Equals("subStorage" == reader.LocalName)) | 42 | if (reader.LocalName != "subStorage") |
| 43 | { | 43 | { |
| 44 | throw new XmlException(); | 44 | throw new XmlException(); |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | WindowsInstallerData data = null; | 47 | WindowsInstallerData data = null; |
| 48 | bool empty = reader.IsEmptyElement; | ||
| 49 | string name = null; | 48 | string name = null; |
| 50 | 49 | ||
| 50 | var empty = reader.IsEmptyElement; | ||
| 51 | |||
| 51 | while (reader.MoveToNextAttribute()) | 52 | while (reader.MoveToNextAttribute()) |
| 52 | { | 53 | { |
| 53 | switch (reader.LocalName) | 54 | switch (reader.LocalName) |
| @@ -60,7 +61,7 @@ namespace WixToolset.Data.WindowsInstaller | |||
| 60 | 61 | ||
| 61 | if (!empty) | 62 | if (!empty) |
| 62 | { | 63 | { |
| 63 | bool done = false; | 64 | var done = false; |
| 64 | 65 | ||
| 65 | while (!done && reader.Read()) | 66 | while (!done && reader.Read()) |
| 66 | { | 67 | { |
| @@ -76,6 +77,7 @@ namespace WixToolset.Data.WindowsInstaller | |||
| 76 | throw new XmlException(); | 77 | throw new XmlException(); |
| 77 | } | 78 | } |
| 78 | break; | 79 | break; |
| 80 | |||
| 79 | case XmlNodeType.EndElement: | 81 | case XmlNodeType.EndElement: |
| 80 | done = true; | 82 | done = true; |
| 81 | break; | 83 | break; |
diff --git a/src/WixToolset.Data/WindowsInstaller/TableDefinitionCollection.cs b/src/WixToolset.Data/WindowsInstaller/TableDefinitionCollection.cs index 80303913..96c5f74f 100644 --- a/src/WixToolset.Data/WindowsInstaller/TableDefinitionCollection.cs +++ b/src/WixToolset.Data/WindowsInstaller/TableDefinitionCollection.cs | |||
| @@ -36,18 +36,12 @@ namespace WixToolset.Data.WindowsInstaller | |||
| 36 | /// Gets the number of items in the collection. | 36 | /// Gets the number of items in the collection. |
| 37 | /// </summary> | 37 | /// </summary> |
| 38 | /// <value>Number of items in collection.</value> | 38 | /// <value>Number of items in collection.</value> |
| 39 | public int Count | 39 | public int Count => this.collection.Count; |
| 40 | { | ||
| 41 | get { return this.collection.Count; } | ||
| 42 | } | ||
| 43 | 40 | ||
| 44 | /// <summary> | 41 | /// <summary> |
| 45 | /// Table definition collections are never read-only. | 42 | /// Table definition collections are never read-only. |
| 46 | /// </summary> | 43 | /// </summary> |
| 47 | public bool IsReadOnly | 44 | public bool IsReadOnly => false; |
| 48 | { | ||
| 49 | get { return false; } | ||
| 50 | } | ||
| 51 | 45 | ||
| 52 | /// <summary> | 46 | /// <summary> |
| 53 | /// Gets a table definition by name. | 47 | /// Gets a table definition by name. |
| @@ -72,10 +66,7 @@ namespace WixToolset.Data.WindowsInstaller | |||
| 72 | /// <param name="tableName">Name of table to locate.</param> | 66 | /// <param name="tableName">Name of table to locate.</param> |
| 73 | /// <param name="table">Table definition if found.</param> | 67 | /// <param name="table">Table definition if found.</param> |
| 74 | /// <returns>True if table definition was found otherwise false.</returns> | 68 | /// <returns>True if table definition was found otherwise false.</returns> |
| 75 | public bool TryGet(string tableName, out TableDefinition table) | 69 | public bool TryGet(string tableName, out TableDefinition table) => this.collection.TryGetValue(tableName, out table); |
| 76 | { | ||
| 77 | return this.collection.TryGetValue(tableName, out table); | ||
| 78 | } | ||
| 79 | 70 | ||
| 80 | /// <summary> | 71 | /// <summary> |
| 81 | /// Load a table definition collection from an XmlReader. | 72 | /// Load a table definition collection from an XmlReader. |
| @@ -95,76 +86,52 @@ namespace WixToolset.Data.WindowsInstaller | |||
| 95 | /// </summary> | 86 | /// </summary> |
| 96 | /// <param name="tableDefinition">Table definition to add to the collection.</param> | 87 | /// <param name="tableDefinition">Table definition to add to the collection.</param> |
| 97 | /// <value>Indexes by table definition name.</value> | 88 | /// <value>Indexes by table definition name.</value> |
| 98 | public void Add(TableDefinition tableDefinition) | 89 | public void Add(TableDefinition tableDefinition) => this.collection.Add(tableDefinition.Name, tableDefinition); |
| 99 | { | ||
| 100 | this.collection.Add(tableDefinition.Name, tableDefinition); | ||
| 101 | } | ||
| 102 | 90 | ||
| 103 | /// <summary> | 91 | /// <summary> |
| 104 | /// Removes all table definitions from the collection. | 92 | /// Removes all table definitions from the collection. |
| 105 | /// </summary> | 93 | /// </summary> |
| 106 | public void Clear() | 94 | public void Clear() => this.collection.Clear(); |
| 107 | { | ||
| 108 | this.collection.Clear(); | ||
| 109 | } | ||
| 110 | 95 | ||
| 111 | /// <summary> | 96 | /// <summary> |
| 112 | /// Checks if the collection contains a table name. | 97 | /// Checks if the collection contains a table name. |
| 113 | /// </summary> | 98 | /// </summary> |
| 114 | /// <param name="tableName">The table to check in the collection.</param> | 99 | /// <param name="tableName">The table to check in the collection.</param> |
| 115 | /// <returns>True if collection contains the table.</returns> | 100 | /// <returns>True if collection contains the table.</returns> |
| 116 | public bool Contains(string tableName) | 101 | public bool Contains(string tableName) => this.collection.ContainsKey(tableName); |
| 117 | { | ||
| 118 | return this.collection.ContainsKey(tableName); | ||
| 119 | } | ||
| 120 | 102 | ||
| 121 | /// <summary> | 103 | /// <summary> |
| 122 | /// Checks if the collection contains a table. | 104 | /// Checks if the collection contains a table. |
| 123 | /// </summary> | 105 | /// </summary> |
| 124 | /// <param name="table">The table to check in the collection.</param> | 106 | /// <param name="table">The table to check in the collection.</param> |
| 125 | /// <returns>True if collection contains the table.</returns> | 107 | /// <returns>True if collection contains the table.</returns> |
| 126 | public bool Contains(TableDefinition table) | 108 | public bool Contains(TableDefinition table) => this.collection.ContainsKey(table.Name); |
| 127 | { | ||
| 128 | return this.collection.ContainsKey(table.Name); | ||
| 129 | } | ||
| 130 | 109 | ||
| 131 | /// <summary> | 110 | /// <summary> |
| 132 | /// Copies table definitions to an arry. | 111 | /// Copies table definitions to an arry. |
| 133 | /// </summary> | 112 | /// </summary> |
| 134 | /// <param name="array">Array to copy the table definitions to.</param> | 113 | /// <param name="array">Array to copy the table definitions to.</param> |
| 135 | /// <param name="index">Index in the array to start copying at.</param> | 114 | /// <param name="index">Index in the array to start copying at.</param> |
| 136 | public void CopyTo(TableDefinition[] array, int index) | 115 | public void CopyTo(TableDefinition[] array, int index) => this.collection.Values.CopyTo(array, index); |
| 137 | { | ||
| 138 | this.collection.Values.CopyTo(array, index); | ||
| 139 | } | ||
| 140 | 116 | ||
| 141 | /// <summary> | 117 | /// <summary> |
| 142 | /// Removes a table definition from the collection. | 118 | /// Removes a table definition from the collection. |
| 143 | /// </summary> | 119 | /// </summary> |
| 144 | /// <param name="table">Table to remove from the collection.</param> | 120 | /// <param name="table">Table to remove from the collection.</param> |
| 145 | /// <returns>True if the table definition existed in the collection and was removed.</returns> | 121 | /// <returns>True if the table definition existed in the collection and was removed.</returns> |
| 146 | public bool Remove(TableDefinition table) | 122 | public bool Remove(TableDefinition table) => this.collection.Remove(table.Name); |
| 147 | { | ||
| 148 | return this.collection.Remove(table.Name); | ||
| 149 | } | ||
| 150 | 123 | ||
| 151 | /// <summary> | 124 | /// <summary> |
| 152 | /// Gets enumerator for the collection. | 125 | /// Gets enumerator for the collection. |
| 153 | /// </summary> | 126 | /// </summary> |
| 154 | /// <returns>Enumerator for the collection.</returns> | 127 | /// <returns>Enumerator for the collection.</returns> |
| 155 | public IEnumerator<TableDefinition> GetEnumerator() | 128 | public IEnumerator<TableDefinition> GetEnumerator() => this.collection.Values.GetEnumerator(); |
| 156 | { | ||
| 157 | return this.collection.Values.GetEnumerator(); | ||
| 158 | } | ||
| 159 | 129 | ||
| 160 | /// <summary> | 130 | /// <summary> |
| 161 | /// Gets the untyped enumerator for the collection. | 131 | /// Gets the untyped enumerator for the collection. |
| 162 | /// </summary> | 132 | /// </summary> |
| 163 | /// <returns>Untyped enumerator for the collection.</returns> | 133 | /// <returns>Untyped enumerator for the collection.</returns> |
| 164 | IEnumerator IEnumerable.GetEnumerator() | 134 | IEnumerator IEnumerable.GetEnumerator() => this.collection.Values.GetEnumerator(); |
| 165 | { | ||
| 166 | return this.collection.Values.GetEnumerator(); | ||
| 167 | } | ||
| 168 | 135 | ||
| 169 | /// <summary> | 136 | /// <summary> |
| 170 | /// Loads a collection of table definitions from a XmlReader in memory. | 137 | /// Loads a collection of table definitions from a XmlReader in memory. |
| @@ -178,8 +145,8 @@ namespace WixToolset.Data.WindowsInstaller | |||
| 178 | throw new XmlException(); | 145 | throw new XmlException(); |
| 179 | } | 146 | } |
| 180 | 147 | ||
| 181 | bool empty = reader.IsEmptyElement; | 148 | var empty = reader.IsEmptyElement; |
| 182 | TableDefinitionCollection tableDefinitionCollection = new TableDefinitionCollection(); | 149 | var tableDefinitionCollection = new TableDefinitionCollection(); |
| 183 | 150 | ||
| 184 | while (reader.MoveToNextAttribute()) | 151 | while (reader.MoveToNextAttribute()) |
| 185 | { | 152 | { |
| @@ -188,7 +155,7 @@ namespace WixToolset.Data.WindowsInstaller | |||
| 188 | // parse the child elements | 155 | // parse the child elements |
| 189 | if (!empty) | 156 | if (!empty) |
| 190 | { | 157 | { |
| 191 | bool done = false; | 158 | var done = false; |
| 192 | 159 | ||
| 193 | while (!done && reader.Read()) | 160 | while (!done && reader.Read()) |
| 194 | { | 161 | { |
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 | } |
diff --git a/src/WixToolset.Data/WindowsInstaller/WindowsInstallerData.cs b/src/WixToolset.Data/WindowsInstaller/WindowsInstallerData.cs index 0855997c..ac593152 100644 --- a/src/WixToolset.Data/WindowsInstaller/WindowsInstallerData.cs +++ b/src/WixToolset.Data/WindowsInstaller/WindowsInstallerData.cs | |||
| @@ -61,6 +61,42 @@ namespace WixToolset.Data.WindowsInstaller | |||
| 61 | public TableIndexedCollection Tables { get; private set; } | 61 | public TableIndexedCollection Tables { get; private set; } |
| 62 | 62 | ||
| 63 | /// <summary> | 63 | /// <summary> |
| 64 | /// Ensure this output contains a particular table. | ||
| 65 | /// </summary> | ||
| 66 | /// <param name="tableDefinition">Definition of the table that should exist.</param> | ||
| 67 | /// <param name="section">Optional section to use for the table. If one is not provided, the entry section will be used.</param> | ||
| 68 | /// <returns>The table in this output.</returns> | ||
| 69 | public Table EnsureTable(TableDefinition tableDefinition) | ||
| 70 | { | ||
| 71 | if (!this.Tables.TryGetTable(tableDefinition.Name, out var table)) | ||
| 72 | { | ||
| 73 | table = new Table(tableDefinition); | ||
| 74 | this.Tables.Add(table); | ||
| 75 | } | ||
| 76 | |||
| 77 | return table; | ||
| 78 | } | ||
| 79 | |||
| 80 | /// <summary> | ||
| 81 | /// Saves an output to a <c>WixOutput</c> container. | ||
| 82 | /// </summary> | ||
| 83 | /// <param name="wixout">Container to save to.</param> | ||
| 84 | public void Save(WixOutput wixout) | ||
| 85 | { | ||
| 86 | using (var writer = XmlWriter.Create(wixout.CreateDataStream(WixOutputStreamName))) | ||
| 87 | { | ||
| 88 | writer.WriteStartDocument(); | ||
| 89 | this.Write(writer); | ||
| 90 | writer.WriteEndDocument(); | ||
| 91 | } | ||
| 92 | } | ||
| 93 | |||
| 94 | /// <summary> | ||
| 95 | /// Gets table by name. | ||
| 96 | /// </summary> | ||
| 97 | public bool TryGetTable(string tableName, out Table table) => this.Tables.TryGetTable(tableName, out table); | ||
| 98 | |||
| 99 | /// <summary> | ||
| 64 | /// Loads an output from a path on disk. | 100 | /// Loads an output from a path on disk. |
| 65 | /// </summary> | 101 | /// </summary> |
| 66 | /// <param name="path">Path to output file saved on disk.</param> | 102 | /// <param name="path">Path to output file saved on disk.</param> |
| @@ -85,20 +121,6 @@ namespace WixToolset.Data.WindowsInstaller | |||
| 85 | } | 121 | } |
| 86 | 122 | ||
| 87 | /// <summary> | 123 | /// <summary> |
| 88 | /// Saves an output to a <c>WixOutput</c> container. | ||
| 89 | /// </summary> | ||
| 90 | /// <param name="wixout">Container to save to.</param> | ||
| 91 | public void Save(WixOutput wixout) | ||
| 92 | { | ||
| 93 | using (var writer = XmlWriter.Create(wixout.CreateDataStream(WixOutputStreamName))) | ||
| 94 | { | ||
| 95 | writer.WriteStartDocument(); | ||
| 96 | this.Write(writer); | ||
| 97 | writer.WriteEndDocument(); | ||
| 98 | } | ||
| 99 | } | ||
| 100 | |||
| 101 | /// <summary> | ||
| 102 | /// Processes an XmlReader and builds up the output object. | 124 | /// Processes an XmlReader and builds up the output object. |
| 103 | /// </summary> | 125 | /// </summary> |
| 104 | /// <param name="reader">Reader to get data from.</param> | 126 | /// <param name="reader">Reader to get data from.</param> |
| @@ -207,23 +229,6 @@ namespace WixToolset.Data.WindowsInstaller | |||
| 207 | } | 229 | } |
| 208 | 230 | ||
| 209 | /// <summary> | 231 | /// <summary> |
| 210 | /// Ensure this output contains a particular table. | ||
| 211 | /// </summary> | ||
| 212 | /// <param name="tableDefinition">Definition of the table that should exist.</param> | ||
| 213 | /// <param name="section">Optional section to use for the table. If one is not provided, the entry section will be used.</param> | ||
| 214 | /// <returns>The table in this output.</returns> | ||
| 215 | public Table EnsureTable(TableDefinition tableDefinition) | ||
| 216 | { | ||
| 217 | if (!this.Tables.TryGetTable(tableDefinition.Name, out var table)) | ||
| 218 | { | ||
| 219 | table = new Table(tableDefinition); | ||
| 220 | this.Tables.Add(table); | ||
| 221 | } | ||
| 222 | |||
| 223 | return table; | ||
| 224 | } | ||
| 225 | |||
| 226 | /// <summary> | ||
| 227 | /// Persists an output in an XML format. | 232 | /// Persists an output in an XML format. |
| 228 | /// </summary> | 233 | /// </summary> |
| 229 | /// <param name="writer">XmlWriter where the Output should persist itself as XML.</param> | 234 | /// <param name="writer">XmlWriter where the Output should persist itself as XML.</param> |
