diff options
| author | Rob Mensching <rob@firegiant.com> | 2021-04-22 05:46:03 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2021-04-29 16:41:44 -0700 |
| commit | c00516901e6b67e398396b14fe7682d0376f8643 (patch) | |
| tree | b0d62089a1c5700c7f2c3e3790750bf2d8ea33c0 /src/api/burn/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs | |
| parent | 8eb98efd2175d9ece2e4639d43081667af9a4990 (diff) | |
| download | wix-c00516901e6b67e398396b14fe7682d0376f8643.tar.gz wix-c00516901e6b67e398396b14fe7682d0376f8643.tar.bz2 wix-c00516901e6b67e398396b14fe7682d0376f8643.zip | |
Move balutil into API/burn
Diffstat (limited to 'src/api/burn/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs')
| -rw-r--r-- | src/api/burn/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/api/burn/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs b/src/api/burn/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs new file mode 100644 index 00000000..ad8a5dc0 --- /dev/null +++ b/src/api/burn/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs | |||
| @@ -0,0 +1,63 @@ | |||
| 1 | // 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 | |||
| 3 | namespace WixToolset.Mba.Core | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.Runtime.InteropServices; | ||
| 7 | |||
| 8 | /// <summary> | ||
| 9 | /// Default implementation of <see cref="IBootstrapperApplicationFactory"/>. | ||
| 10 | /// </summary> | ||
| 11 | public abstract class BaseBootstrapperApplicationFactory : IBootstrapperApplicationFactory | ||
| 12 | { | ||
| 13 | /// <summary> | ||
| 14 | /// Default implementation of <see cref="IBootstrapperApplicationFactory.Create(IntPtr, IntPtr)"/> | ||
| 15 | /// </summary> | ||
| 16 | /// <param name="pArgs"></param> | ||
| 17 | /// <param name="pResults"></param> | ||
| 18 | public void Create(IntPtr pArgs, IntPtr pResults) | ||
| 19 | { | ||
| 20 | InitializeFromCreateArgs(pArgs, out var engine, out var bootstrapperCommand); | ||
| 21 | |||
| 22 | var ba = this.Create(engine, bootstrapperCommand); | ||
| 23 | StoreBAInCreateResults(pResults, ba); | ||
| 24 | } | ||
| 25 | |||
| 26 | /// <summary> | ||
| 27 | /// Called by <see cref="BaseBootstrapperApplicationFactory.Create(IntPtr, IntPtr)"/> to get the <see cref="IBootstrapperApplication"/>. | ||
| 28 | /// </summary> | ||
| 29 | /// <param name="engine">The bundle engine.</param> | ||
| 30 | /// <param name="bootstrapperCommand">Command information passed from the engine for the BA to perform.</param> | ||
| 31 | /// <returns>The <see cref="IBootstrapperApplication"/> for the bundle.</returns> | ||
| 32 | protected abstract IBootstrapperApplication Create(IEngine engine, IBootstrapperCommand bootstrapperCommand); | ||
| 33 | |||
| 34 | /// <summary> | ||
| 35 | /// Initializes the native part of <see cref="WixToolset.Mba.Core"/>. | ||
| 36 | /// Most users should inherit from <see cref="BaseBootstrapperApplicationFactory"/> instead of calling this method. | ||
| 37 | /// </summary> | ||
| 38 | /// <param name="pArgs">The args struct given by the engine when initially creating the BA.</param> | ||
| 39 | /// <param name="engine">The bundle engine interface.</param> | ||
| 40 | /// <param name="bootstrapperCommand">The context of the current run of the bundle.</param> | ||
| 41 | public static void InitializeFromCreateArgs(IntPtr pArgs, out IEngine engine, out IBootstrapperCommand bootstrapperCommand) | ||
| 42 | { | ||
| 43 | Command pCommand = new Command | ||
| 44 | { | ||
| 45 | cbSize = Marshal.SizeOf(typeof(Command)) | ||
| 46 | }; | ||
| 47 | var pEngine = BalUtil.InitializeFromCreateArgs(pArgs, ref pCommand); | ||
| 48 | engine = new Engine(pEngine); | ||
| 49 | bootstrapperCommand = pCommand.GetBootstrapperCommand(); | ||
| 50 | } | ||
| 51 | |||
| 52 | /// <summary> | ||
| 53 | /// Registers the BA with the engine using the default mapping between the message based interface and the COM interface. | ||
| 54 | /// Most users should inherit from <see cref="BaseBootstrapperApplicationFactory"/> instead of calling this method. | ||
| 55 | /// </summary> | ||
| 56 | /// <param name="pResults">The results struct given by the engine when initially creating the BA</param> | ||
| 57 | /// <param name="ba">The <see cref="IBootstrapperApplication"/>.</param> | ||
| 58 | public static void StoreBAInCreateResults(IntPtr pResults, IBootstrapperApplication ba) | ||
| 59 | { | ||
| 60 | BalUtil.StoreBAInCreateResults(pResults, ba); | ||
| 61 | } | ||
| 62 | } | ||
| 63 | } | ||
