using Edge.Core.Processor;using Edge.Core.IndustryStandardInterface.Pump; using Edge.Core.IndustryStandardInterface.ATG; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using System; using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; namespace Applications.UniversalApi_WebConsole_App { public class App : IAppProcessor { private ILogger logger = NullLogger.Instance; private string baseUrl; public App(IServiceProvider services, string baseUrl) { this.baseUrl = baseUrl; if (services != null) { var loggerFactory = services.GetRequiredService<ILoggerFactory>(); this.logger = loggerFactory.CreateLogger("Application"); } } public string MetaConfigName { get; set; } public void Init(IEnumerable<IProcessor> processors) { } IHost webHost; public Task<bool> Start() { if (string.IsNullOrEmpty(this.baseUrl)) this.baseUrl = "http://localhost:8888/"; this.webHost = Program.CreateHostBuilder(new string[] { this.baseUrl }).Build(); this.webHost.RunAsync(); return Task.FromResult(true); } public async Task<bool> Stop() { await this.webHost?.StopAsync(); this.webHost?.Dispose(); return true; } } }