aboutsummaryrefslogtreecommitdiff
path: root/src/api/burn/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2021-05-11 07:42:09 -0700
committerRob Mensching <rob@firegiant.com>2021-05-11 07:42:09 -0700
commit8e1207c4c5e451ba1a087f0fa11b63964ac35f3c (patch)
tree8cdfc18d38f25a5fb8e63f115d3447b11172e1e5 /src/api/burn/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs
parent6fa3bf7fe67e25650d5a2b6bec09a9813b1a4722 (diff)
parentc00516901e6b67e398396b14fe7682d0376f8643 (diff)
downloadwix-8e1207c4c5e451ba1a087f0fa11b63964ac35f3c.tar.gz
wix-8e1207c4c5e451ba1a087f0fa11b63964ac35f3c.tar.bz2
wix-8e1207c4c5e451ba1a087f0fa11b63964ac35f3c.zip
Merge balutil
Diffstat (limited to 'src/api/burn/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs')
-rw-r--r--src/api/burn/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs63
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
3namespace 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}