|
| 1 | +namespace ElectronNET.Runtime |
| 2 | +{ |
| 3 | + using System.Collections.Immutable; |
| 4 | + using ElectronNET.Runtime.Controllers; |
| 5 | + using ElectronNET.Runtime.Data; |
| 6 | + |
| 7 | + /// <summary> |
| 8 | + /// Default implementation of <see cref="IElectronHost"/> that keeps track of the |
| 9 | + /// runtime state shared between the Electron.NET CLI bootstrapper and ASP.NET |
| 10 | + /// applications. |
| 11 | + /// </summary> |
| 12 | + public sealed class ElectronHost : IElectronHost |
| 13 | + { |
| 14 | + private readonly StartupManager startupManager; |
| 15 | + |
| 16 | + public ElectronHost() |
| 17 | + { |
| 18 | + this.Options = new ElectronNetOptions(); |
| 19 | + this.startupManager = new StartupManager(this); |
| 20 | + this.startupManager.Initialize(); |
| 21 | + } |
| 22 | + |
| 23 | + public string ElectronExtraArguments { get; set; } |
| 24 | + |
| 25 | + public int? ElectronSocketPort { get; set; } |
| 26 | + |
| 27 | + public int? AspNetWebPort { get; set; } |
| 28 | + |
| 29 | + public StartupMethod StartupMethod { get; set; } |
| 30 | + |
| 31 | + public DotnetAppType DotnetAppType { get; set; } |
| 32 | + |
| 33 | + public string ElectronExecutable { get; set; } |
| 34 | + |
| 35 | + public ImmutableList<string> ProcessArguments { get; set; } |
| 36 | + |
| 37 | + public BuildInfo BuildInfo { get; set; } |
| 38 | + |
| 39 | + public IElectronNetRuntimeController RuntimeController => this.RuntimeControllerCore; |
| 40 | + |
| 41 | + public int? ElectronProcessId { get; set; } |
| 42 | + |
| 43 | + public ElectronNetOptions Options { get; private set; } |
| 44 | + |
| 45 | + internal RuntimeControllerBase RuntimeControllerCore { get; set; } |
| 46 | + |
| 47 | + public SocketIoFacade GetSocket() |
| 48 | + { |
| 49 | + return this.RuntimeControllerCore?.Socket; |
| 50 | + } |
| 51 | + |
| 52 | + public void ApplyOptions(ElectronNetOptions options) |
| 53 | + { |
| 54 | + this.Options = options ?? new ElectronNetOptions(); |
| 55 | + } |
| 56 | + } |
| 57 | +} |
0 commit comments