Dipper/Dipper.Alioth/Web/WebStarHost.cs

45 lines
887 B
C#
Raw Permalink Normal View History

2022-11-27 18:05:18 +08:00
2022-11-06 22:42:32 +08:00
namespace Dipper.Alioth.Web;
2022-11-27 17:23:54 +08:00
/// <summary>
/// 封装统一主机
/// 暂时不使用
/// </summary>
2022-11-09 22:06:06 +08:00
public class WebStarHost : StarHost
2022-11-06 22:42:32 +08:00
{
2022-11-09 22:06:06 +08:00
private WebStarHost()
2022-11-06 23:03:52 +08:00
{
}
2022-11-09 22:06:06 +08:00
public static WebStarHost CreateWebHost()
2022-11-06 23:03:52 +08:00
{
2022-11-09 22:06:06 +08:00
return new WebStarHost();
2022-11-06 23:03:52 +08:00
}
2022-11-09 22:06:06 +08:00
public override void Run(string[] args, Action<StarOption> action)
2022-11-06 22:42:32 +08:00
{
var app = Configure(args, action);
app.Run();
}
2022-11-09 22:06:06 +08:00
public override Task RunAsync(string[] args, Action<StarOption> action)
2022-11-06 22:42:32 +08:00
{
var app = Configure(args, action);
return app.RunAsync();
}
2022-11-06 23:03:52 +08:00
private WebApplication Configure(string[] args, Action<StarOption> action)
2022-11-06 22:42:32 +08:00
{
var builder = WebApplication.CreateBuilder(args);
2022-11-09 22:06:06 +08:00
builder.AddStarApp(action);
2022-11-06 22:42:32 +08:00
var app = builder.Build();
2022-11-09 22:06:06 +08:00
2022-11-27 17:23:54 +08:00
app.UseStarApp();
2022-11-06 22:42:32 +08:00
return app;
}
}