diff options
| author | Bob Arnson <bob@firegiant.com> | 2020-02-13 14:28:58 -0500 |
|---|---|---|
| committer | Bob Arnson <bob@firegiant.com> | 2020-02-13 15:07:43 -0500 |
| commit | add525424e44a050d3f98f64e56a85ab5d79955d (patch) | |
| tree | ad02f4f8afe6dfb84db1fc10627058fc1ffe61fc /src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs | |
| parent | 7116076d1af5af5f9da51a263a3b8b6a4a2e4ab8 (diff) | |
| download | wix-add525424e44a050d3f98f64e56a85ab5d79955d.tar.gz wix-add525424e44a050d3f98f64e56a85ab5d79955d.tar.bz2 wix-add525424e44a050d3f98f64e56a85ab5d79955d.zip | |
Make BindResult disposable to manage WixOutput disposability.
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs')
| -rw-r--r-- | src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs | 55 |
1 files changed, 15 insertions, 40 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs index 1bcaf209..a90517da 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs | |||
| @@ -17,13 +17,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 17 | /// <summary> | 17 | /// <summary> |
| 18 | /// Binds a databse. | 18 | /// Binds a databse. |
| 19 | /// </summary> | 19 | /// </summary> |
| 20 | internal class BindDatabaseCommand : IDisposable | 20 | internal class BindDatabaseCommand |
| 21 | { | 21 | { |
| 22 | // As outlined in RFC 4122, this is our namespace for generating name-based (version 3) UUIDs. | 22 | // As outlined in RFC 4122, this is our namespace for generating name-based (version 3) UUIDs. |
| 23 | internal static readonly Guid WixComponentGuidNamespace = new Guid("{3064E5C6-FB63-4FE9-AC49-E446A792EFA5}"); | 23 | internal static readonly Guid WixComponentGuidNamespace = new Guid("{3064E5C6-FB63-4FE9-AC49-E446A792EFA5}"); |
| 24 | 24 | ||
| 25 | private bool disposed; | ||
| 26 | |||
| 27 | public BindDatabaseCommand(IBindContext context, IEnumerable<IWindowsInstallerBackendBinderExtension> backendExtension, Validator validator):this(context, backendExtension, null, validator) | 25 | public BindDatabaseCommand(IBindContext context, IEnumerable<IWindowsInstallerBackendBinderExtension> backendExtension, Validator validator):this(context, backendExtension, null, validator) |
| 28 | { | 26 | { |
| 29 | } | 27 | } |
| @@ -97,13 +95,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 97 | 95 | ||
| 98 | private Validator Validator { get; } | 96 | private Validator Validator { get; } |
| 99 | 97 | ||
| 100 | public IEnumerable<IFileTransfer> FileTransfers { get; private set; } | 98 | public IBindResult Execute() |
| 101 | |||
| 102 | public IEnumerable<ITrackedFile> TrackedFiles { get; private set; } | ||
| 103 | |||
| 104 | public WixOutput Wixout { get; private set; } | ||
| 105 | |||
| 106 | public void Execute() | ||
| 107 | { | 99 | { |
| 108 | var section = this.Intermediate.Sections.Single(); | 100 | var section = this.Intermediate.Sections.Single(); |
| 109 | 101 | ||
| @@ -218,7 +210,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 218 | 210 | ||
| 219 | if (this.Messaging.EncounteredError) | 211 | if (this.Messaging.EncounteredError) |
| 220 | { | 212 | { |
| 221 | return; | 213 | return null; |
| 222 | } | 214 | } |
| 223 | 215 | ||
| 224 | // Call extension | 216 | // Call extension |
| @@ -290,7 +282,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 290 | // stop processing if an error previously occurred | 282 | // stop processing if an error previously occurred |
| 291 | if (this.Messaging.EncounteredError) | 283 | if (this.Messaging.EncounteredError) |
| 292 | { | 284 | { |
| 293 | return; | 285 | return null; |
| 294 | } | 286 | } |
| 295 | 287 | ||
| 296 | // Gather information about files that do not come from merge modules. | 288 | // Gather information about files that do not come from merge modules. |
| @@ -322,7 +314,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 322 | // stop processing if an error previously occurred | 314 | // stop processing if an error previously occurred |
| 323 | if (this.Messaging.EncounteredError) | 315 | if (this.Messaging.EncounteredError) |
| 324 | { | 316 | { |
| 325 | return; | 317 | return null; |
| 326 | } | 318 | } |
| 327 | 319 | ||
| 328 | // Now that the variable cache is populated, resolve any delayed fields. | 320 | // Now that the variable cache is populated, resolve any delayed fields. |
| @@ -347,7 +339,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 347 | // stop processing if an error previously occurred | 339 | // stop processing if an error previously occurred |
| 348 | if (this.Messaging.EncounteredError) | 340 | if (this.Messaging.EncounteredError) |
| 349 | { | 341 | { |
| 350 | return; | 342 | return null; |
| 351 | } | 343 | } |
| 352 | 344 | ||
| 353 | // Time to create the output object. Try to put as much above here as possible, updating the IR is better. | 345 | // Time to create the output object. Try to put as much above here as possible, updating the IR is better. |
| @@ -425,7 +417,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 425 | // Stop processing if an error previously occurred. | 417 | // Stop processing if an error previously occurred. |
| 426 | if (this.Messaging.EncounteredError) | 418 | if (this.Messaging.EncounteredError) |
| 427 | { | 419 | { |
| 428 | return; | 420 | return null; |
| 429 | } | 421 | } |
| 430 | 422 | ||
| 431 | // Ensure the intermediate folder is created since delta patches will be | 423 | // Ensure the intermediate folder is created since delta patches will be |
| @@ -479,7 +471,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 479 | // stop processing if an error previously occurred | 471 | // stop processing if an error previously occurred |
| 480 | if (this.Messaging.EncounteredError) | 472 | if (this.Messaging.EncounteredError) |
| 481 | { | 473 | { |
| 482 | return; | 474 | return null; |
| 483 | } | 475 | } |
| 484 | 476 | ||
| 485 | // Generate database file. | 477 | // Generate database file. |
| @@ -496,7 +488,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 496 | // Stop processing if an error previously occurred. | 488 | // Stop processing if an error previously occurred. |
| 497 | if (this.Messaging.EncounteredError) | 489 | if (this.Messaging.EncounteredError) |
| 498 | { | 490 | { |
| 499 | return; | 491 | return null; |
| 500 | } | 492 | } |
| 501 | 493 | ||
| 502 | // Merge modules. | 494 | // Merge modules. |
| @@ -533,7 +525,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 533 | 525 | ||
| 534 | if (this.Messaging.EncounteredError) | 526 | if (this.Messaging.EncounteredError) |
| 535 | { | 527 | { |
| 536 | return; | 528 | return null; |
| 537 | } | 529 | } |
| 538 | 530 | ||
| 539 | #if TODO_FINISH_VALIDATION | 531 | #if TODO_FINISH_VALIDATION |
| @@ -580,10 +572,12 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 580 | trackedFiles.AddRange(fileFacades.Select(f => this.BackendHelper.TrackFile(f.SourcePath, TrackedFileType.Input, f.SourceLineNumber))); | 572 | trackedFiles.AddRange(fileFacades.Select(f => this.BackendHelper.TrackFile(f.SourcePath, TrackedFileType.Input, f.SourceLineNumber))); |
| 581 | } | 573 | } |
| 582 | 574 | ||
| 583 | this.Wixout = this.CreateWixout(trackedFiles, this.Intermediate, output); | 575 | var result = this.ServiceProvider.GetService<IBindResult>(); |
| 576 | result.FileTransfers = fileTransfers; | ||
| 577 | result.TrackedFiles = trackedFiles; | ||
| 578 | result.Wixout = this.CreateWixout(trackedFiles, this.Intermediate, output); | ||
| 584 | 579 | ||
| 585 | this.FileTransfers = fileTransfers; | 580 | return result; |
| 586 | this.TrackedFiles = trackedFiles; | ||
| 587 | } | 581 | } |
| 588 | 582 | ||
| 589 | private WixOutput CreateWixout(List<ITrackedFile> trackedFiles, Intermediate intermediate, WindowsInstallerData output) | 583 | private WixOutput CreateWixout(List<ITrackedFile> trackedFiles, Intermediate intermediate, WindowsInstallerData output) |
| @@ -984,24 +978,5 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 984 | 978 | ||
| 985 | return command.GeneratedTemporaryFiles; | 979 | return command.GeneratedTemporaryFiles; |
| 986 | } | 980 | } |
| 987 | |||
| 988 | #region IDisposable Support | ||
| 989 | |||
| 990 | public void Dispose() => this.Dispose(true); | ||
| 991 | |||
| 992 | protected virtual void Dispose(bool disposing) | ||
| 993 | { | ||
| 994 | if (!this.disposed) | ||
| 995 | { | ||
| 996 | if (disposing) | ||
| 997 | { | ||
| 998 | this.Wixout?.Dispose(); | ||
| 999 | } | ||
| 1000 | |||
| 1001 | this.disposed = true; | ||
| 1002 | } | ||
| 1003 | } | ||
| 1004 | |||
| 1005 | #endregion | ||
| 1006 | } | 981 | } |
| 1007 | } | 982 | } |
