From c00516901e6b67e398396b14fe7682d0376f8643 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Thu, 22 Apr 2021 05:46:03 -0700 Subject: Move balutil into API/burn --- .../BaseBootstrapperApplicationFactory.cs | 63 ++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 src/api/burn/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs (limited to 'src/api/burn/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs') 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 @@ +// 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. + +namespace WixToolset.Mba.Core +{ + using System; + using System.Runtime.InteropServices; + + /// + /// Default implementation of . + /// + public abstract class BaseBootstrapperApplicationFactory : IBootstrapperApplicationFactory + { + /// + /// Default implementation of + /// + /// + /// + public void Create(IntPtr pArgs, IntPtr pResults) + { + InitializeFromCreateArgs(pArgs, out var engine, out var bootstrapperCommand); + + var ba = this.Create(engine, bootstrapperCommand); + StoreBAInCreateResults(pResults, ba); + } + + /// + /// Called by to get the . + /// + /// The bundle engine. + /// Command information passed from the engine for the BA to perform. + /// The for the bundle. + protected abstract IBootstrapperApplication Create(IEngine engine, IBootstrapperCommand bootstrapperCommand); + + /// + /// Initializes the native part of . + /// Most users should inherit from instead of calling this method. + /// + /// The args struct given by the engine when initially creating the BA. + /// The bundle engine interface. + /// The context of the current run of the bundle. + public static void InitializeFromCreateArgs(IntPtr pArgs, out IEngine engine, out IBootstrapperCommand bootstrapperCommand) + { + Command pCommand = new Command + { + cbSize = Marshal.SizeOf(typeof(Command)) + }; + var pEngine = BalUtil.InitializeFromCreateArgs(pArgs, ref pCommand); + engine = new Engine(pEngine); + bootstrapperCommand = pCommand.GetBootstrapperCommand(); + } + + /// + /// Registers the BA with the engine using the default mapping between the message based interface and the COM interface. + /// Most users should inherit from instead of calling this method. + /// + /// The results struct given by the engine when initially creating the BA + /// The . + public static void StoreBAInCreateResults(IntPtr pResults, IBootstrapperApplication ba) + { + BalUtil.StoreBAInCreateResults(pResults, ba); + } + } +} -- cgit v1.2.3-55-g6feb