DocSpace-client/products/ASC.CRM/Server/Program.cs

57 lines
1.9 KiB
C#
Raw Normal View History

2020-03-02 15:38:31 +00:00
using System;
using System.Collections.Generic;
2020-04-16 19:41:37 +00:00
using System.IO;
2020-03-02 15:38:31 +00:00
using System.Linq;
using System.Threading.Tasks;
2021-03-02 16:29:07 +00:00
using Autofac.Extensions.DependencyInjection;
2020-03-02 15:38:31 +00:00
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace ASC.CRM
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
2021-03-02 16:29:07 +00:00
public static IHostBuilder CreateHostBuilder(string[] args)
{
return Host.CreateDefaultBuilder(args)
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
2020-03-02 15:38:31 +00:00
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
2020-04-16 19:41:37 +00:00
})
2021-03-02 16:29:07 +00:00
.ConfigureAppConfiguration((hostingContext, config) =>
2020-04-16 19:41:37 +00:00
{
2021-03-02 16:29:07 +00:00
var buided = config.Build();
var path = buided["pathToConf"];
if (!Path.IsPathRooted(path))
2020-04-16 19:41:37 +00:00
{
2021-03-02 16:29:07 +00:00
path = Path.GetFullPath(Path.Combine(hostingContext.HostingEnvironment.ContentRootPath, path));
}
config.SetBasePath(path);
config
2020-04-16 19:41:37 +00:00
.AddJsonFile("appsettings.json")
.AddJsonFile($"appsettings.{hostingContext.HostingEnvironment.EnvironmentName}.json", true)
.AddJsonFile("storage.json")
.AddJsonFile("kafka.json")
.AddJsonFile($"kafka.{hostingContext.HostingEnvironment.EnvironmentName}.json", true)
2021-03-02 16:29:07 +00:00
.AddEnvironmentVariables()
.AddCommandLine(args)
.AddInMemoryCollection(new Dictionary<string, string>
{
{"pathToConf", path}
});
});
}
2020-03-02 15:38:31 +00:00
}
}