aboutsummaryrefslogtreecommitdiff
path: root/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs')
-rw-r--r--src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs149
1 files changed, 74 insertions, 75 deletions
diff --git a/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs b/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs
index a0ec6ab9..98b34217 100644
--- a/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs
+++ b/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs
@@ -13,23 +13,15 @@ namespace WixToolset.Mba.Core
13 public abstract class BootstrapperApplication : MarshalByRefObject, IDefaultBootstrapperApplication 13 public abstract class BootstrapperApplication : MarshalByRefObject, IDefaultBootstrapperApplication
14 { 14 {
15 /// <summary> 15 /// <summary>
16 /// Specifies whether this bootstrapper should run asynchronously. The default is true.
17 /// </summary>
18 protected readonly bool asyncExecution;
19
20 /// <summary>
21 /// Gets the <see cref="IEngine"/> for interaction with the engine. 16 /// Gets the <see cref="IEngine"/> for interaction with the engine.
22 /// </summary> 17 /// </summary>
23 protected readonly IEngine engine; 18 protected IEngine engine;
24 19
25 /// <summary> 20 /// <inheritdoc/>
26 /// Creates a new instance of the <see cref="BootstrapperApplication"/> class. 21 public event EventHandler<CreateEventArgs> Create;
27 /// </summary> 22
28 protected BootstrapperApplication(IEngine engine) 23 /// <inheritdoc/>
29 { 24 public event EventHandler<DestroyEventArgs> Destroy;
30 this.engine = engine;
31 this.asyncExecution = true;
32 }
33 25
34 /// <inheritdoc/> 26 /// <inheritdoc/>
35 public event EventHandler<StartupEventArgs> Startup; 27 public event EventHandler<StartupEventArgs> Startup;
@@ -266,12 +258,6 @@ namespace WixToolset.Mba.Core
266 public event EventHandler<CachePayloadExtractCompleteEventArgs> CachePayloadExtractComplete; 258 public event EventHandler<CachePayloadExtractCompleteEventArgs> CachePayloadExtractComplete;
267 259
268 /// <inheritdoc/> 260 /// <inheritdoc/>
269 public event EventHandler<SetUpdateBeginEventArgs> SetUpdateBegin;
270
271 /// <inheritdoc/>
272 public event EventHandler<SetUpdateCompleteEventArgs> SetUpdateComplete;
273
274 /// <inheritdoc/>
275 public event EventHandler<PlanRestoreRelatedBundleEventArgs> PlanRestoreRelatedBundle; 261 public event EventHandler<PlanRestoreRelatedBundleEventArgs> PlanRestoreRelatedBundle;
276 262
277 /// <inheritdoc/> 263 /// <inheritdoc/>
@@ -284,35 +270,73 @@ namespace WixToolset.Mba.Core
284 public event EventHandler<CachePackageNonVitalValidationFailureEventArgs> CachePackageNonVitalValidationFailure; 270 public event EventHandler<CachePackageNonVitalValidationFailureEventArgs> CachePackageNonVitalValidationFailure;
285 271
286 /// <summary> 272 /// <summary>
273 /// The default constructor.
274 /// </summary>
275 /// <remarks>
276 /// The engine object will be valid after handling the OnCreate() event.
277 /// </remarks>
278 protected BootstrapperApplication()
279 {
280 }
281
282 /// <summary>
283 /// This constructor is no longer used.
284 /// </summary>
285 [Obsolete("This constructor is no longer used. Use the default constructor. The engine object will be valid after handling the OnCreate() event.")]
286 protected BootstrapperApplication(IEngine engine)
287 {
288 throw new NotImplementedException("This constructor is no longer used. Use the default constructor. The engine object will be valid after handling the OnCreate() event.");
289 }
290
291 /// <summary>
287 /// Entry point that is called when the bootstrapper application is ready to run. 292 /// Entry point that is called when the bootstrapper application is ready to run.
288 /// </summary> 293 /// </summary>
289 protected abstract void Run(); 294 protected abstract void Run();
290 295
291 /// <summary> 296 /// <summary>
292 /// Called by the engine, raises the <see cref="Startup"/> event. 297 /// Called by the engine, raises the <see cref="Create"/> event.
293 /// </summary> 298 /// </summary>
294 /// <param name="args">Additional arguments for this event.</param> 299 /// <param name="args">Additional arguments for this event.</param>
295 protected virtual void OnStartup(StartupEventArgs args) 300 protected virtual void OnCreate(CreateEventArgs args)
296 { 301 {
297 EventHandler<StartupEventArgs> handler = this.Startup; 302 this.engine = args.Engine;
303
304 EventHandler<CreateEventArgs> handler = this.Create;
298 if (null != handler) 305 if (null != handler)
299 { 306 {
300 handler(this, args); 307 handler(this, args);
301 } 308 }
309 }
302 310
303 if (this.asyncExecution) 311 /// <summary>
312 /// Called by the engine, raises the <see cref="Destroy"/> event.
313 /// </summary>
314 /// <param name="args">Additional arguments for this event.</param>
315 protected virtual void OnDestroy(DestroyEventArgs args)
316 {
317 EventHandler<DestroyEventArgs> handler = this.Destroy;
318 if (null != handler)
304 { 319 {
305 this.engine.Log(LogLevel.Verbose, "Creating BA thread to run asynchronously."); 320 handler(this, args);
306 Thread uiThread = new Thread(this.Run);
307 uiThread.Name = "UIThread";
308 uiThread.SetApartmentState(ApartmentState.STA);
309 uiThread.Start();
310 } 321 }
311 else 322 }
323
324 /// <summary>
325 /// Called by the engine, raises the <see cref="Startup"/> event.
326 /// </summary>
327 /// <param name="args">Additional arguments for this event.</param>
328 protected virtual void OnStartup(StartupEventArgs args)
329 {
330 EventHandler<StartupEventArgs> handler = this.Startup;
331 if (null != handler)
312 { 332 {
313 this.engine.Log(LogLevel.Verbose, "Creating BA thread to run synchronously."); 333 handler(this, args);
314 this.Run();
315 } 334 }
335
336 Thread uiThread = new Thread(this.Run);
337 uiThread.Name = "UIThread";
338 uiThread.SetApartmentState(ApartmentState.STA);
339 uiThread.Start();
316 } 340 }
317 341
318 /// <summary> 342 /// <summary>
@@ -1315,31 +1339,6 @@ namespace WixToolset.Mba.Core
1315 } 1339 }
1316 } 1340 }
1317 1341
1318 /// <summary>
1319 /// Called by the engine, raises the <see cref="SetUpdateBegin"/> event.
1320 /// </summary>
1321 /// <param name="args">Additional arguments for this event.</param>
1322 protected virtual void OnSetUpdateBegin(SetUpdateBeginEventArgs args)
1323 {
1324 EventHandler<SetUpdateBeginEventArgs> handler = this.SetUpdateBegin;
1325 if (null != handler)
1326 {
1327 handler(this, args);
1328 }
1329 }
1330
1331 /// <summary>
1332 /// Called by the engine, raises the <see cref="SetUpdateComplete"/> event.
1333 /// </summary>
1334 /// <param name="args">Additional arguments for this event.</param>
1335 protected virtual void OnSetUpdateComplete(SetUpdateCompleteEventArgs args)
1336 {
1337 EventHandler<SetUpdateCompleteEventArgs> handler = this.SetUpdateComplete;
1338 if (null != handler)
1339 {
1340 handler(this, args);
1341 }
1342 }
1343 1342
1344 /// <summary> 1343 /// <summary>
1345 /// Called by the engine, raises the <see cref="PlanRestoreRelatedBundle"/> event. 1344 /// Called by the engine, raises the <see cref="PlanRestoreRelatedBundle"/> event.
@@ -1395,7 +1394,7 @@ namespace WixToolset.Mba.Core
1395 1394
1396 #region IBootstrapperApplication Members 1395 #region IBootstrapperApplication Members
1397 1396
1398 int IBootstrapperApplication.BAProc(int message, IntPtr pvArgs, IntPtr pvResults, IntPtr pvContext) 1397 int IBootstrapperApplication.BAProc(int message, IntPtr pvArgs, IntPtr pvResults)
1399 { 1398 {
1400 switch (message) 1399 switch (message)
1401 { 1400 {
@@ -1404,8 +1403,24 @@ namespace WixToolset.Mba.Core
1404 } 1403 }
1405 } 1404 }
1406 1405
1407 void IBootstrapperApplication.BAProcFallback(int message, IntPtr pvArgs, IntPtr pvResults, ref int phr, IntPtr pvContext) 1406 void IBootstrapperApplication.BAProcFallback(int message, IntPtr pvArgs, IntPtr pvResults, ref int phr)
1407 {
1408 }
1409
1410 int IBootstrapperApplication.OnCreate(IBootstrapperEngine engine, ref Command command)
1408 { 1411 {
1412 CreateEventArgs args = new CreateEventArgs(new Engine(engine), command.GetBootstrapperCommand());
1413 this.OnCreate(args);
1414
1415 return args.HResult;
1416 }
1417
1418 int IBootstrapperApplication.OnDestroy(bool reload)
1419 {
1420 DestroyEventArgs args = new DestroyEventArgs(reload);
1421 this.OnDestroy(args);
1422
1423 return args.HResult;
1409 } 1424 }
1410 1425
1411 int IBootstrapperApplication.OnStartup() 1426 int IBootstrapperApplication.OnStartup()
@@ -2107,22 +2122,6 @@ namespace WixToolset.Mba.Core
2107 return args.HResult; 2122 return args.HResult;
2108 } 2123 }
2109 2124
2110 int IBootstrapperApplication.OnSetUpdateBegin()
2111 {
2112 SetUpdateBeginEventArgs args = new SetUpdateBeginEventArgs();
2113 this.OnSetUpdateBegin(args);
2114
2115 return args.HResult;
2116 }
2117
2118 int IBootstrapperApplication.OnSetUpdateComplete(int hrStatus, string wzPreviousPackageId, string wzNewPackageId)
2119 {
2120 SetUpdateCompleteEventArgs args = new SetUpdateCompleteEventArgs(hrStatus, wzPreviousPackageId, wzNewPackageId);
2121 this.OnSetUpdateComplete(args);
2122
2123 return args.HResult;
2124 }
2125
2126 int IBootstrapperApplication.OnPlanRestoreRelatedBundle(string wzBundleId, RequestState recommendedState, ref RequestState pRequestedState, ref bool fCancel) 2125 int IBootstrapperApplication.OnPlanRestoreRelatedBundle(string wzBundleId, RequestState recommendedState, ref RequestState pRequestedState, ref bool fCancel)
2127 { 2126 {
2128 PlanRestoreRelatedBundleEventArgs args = new PlanRestoreRelatedBundleEventArgs(wzBundleId, recommendedState, pRequestedState, fCancel); 2127 PlanRestoreRelatedBundleEventArgs args = new PlanRestoreRelatedBundleEventArgs(wzBundleId, recommendedState, pRequestedState, fCancel);