-
Notifications
You must be signed in to change notification settings - Fork 74
Expand file tree
/
Copy pathWindowsStrategy.cs
More file actions
77 lines (69 loc) · 2.59 KB
/
Copy pathWindowsStrategy.cs
File metadata and controls
77 lines (69 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using System;
using System.Diagnostics;
using GeneralUpdate.Common.FileBasic;
using GeneralUpdate.Common.Internal;
using GeneralUpdate.Common.Internal.Event;
using GeneralUpdate.Common.Internal.Pipeline;
using GeneralUpdate.Common.Internal.Strategy;
using GeneralUpdate.Common.Shared;
using GeneralUpdate.Common.Shared.Object;
using GeneralUpdate.Core.Pipeline;
namespace GeneralUpdate.Core.Strategys
{
/// <summary>
/// Update policy based on the Windows platform.
/// </summary>
public class WindowsStrategy : AbstractStrategy
{
protected override PipelineContext CreatePipelineContext(VersionInfo version, string patchPath)
{
var context = base.CreatePipelineContext(version, patchPath);
// Driver middleware (Windows-specific)
if (_configinfo.DriveEnabled == true)
{
context.Add("DriverDirectory", _configinfo.DriverDirectory);
}
return context;
}
protected override PipelineBuilder BuildPipeline(PipelineContext context)
{
var builder = new PipelineBuilder(context)
.UseMiddlewareIf<PatchMiddleware>(_configinfo.PatchEnabled)
.UseMiddleware<CompressMiddleware>()
.UseMiddleware<HashMiddleware>();
#if NET8_0_OR_GREATER
builder.UseMiddlewareIf<DrivelutionMiddleware>(_configinfo.DriveEnabled == true);
#endif
return builder;
}
protected override void OnExecuteComplete()
{
StartApp();
}
public override void StartApp()
{
try
{
var mainAppPath = CheckPath(_configinfo.InstallPath, _configinfo.MainAppName);
if (string.IsNullOrEmpty(mainAppPath))
throw new Exception($"Can't find the app {mainAppPath}!");
Process.Start(mainAppPath);
var bowlAppPath = CheckPath(_configinfo.InstallPath, _configinfo.Bowl);
if (!string.IsNullOrEmpty(bowlAppPath))
{
Process.Start(bowlAppPath);
}
}
catch (Exception e)
{
GeneralTracer.Error("The StartApp method in the GeneralUpdate.Core.WindowsStrategy class throws an exception.", e);
EventManager.Instance.Dispatch(this, new ExceptionEventArgs(e, e.Message));
}
finally
{
GeneralTracer.Dispose();
Process.GetCurrentProcess().Kill();
}
}
}
}