60 lines
1.7 KiB
C#
60 lines
1.7 KiB
C#
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using NLog;
|
|
using System.Net;
|
|
using System.Runtime.CompilerServices;
|
|
using YieldChain.Commons;
|
|
using YLErp.Modules.DataCacheModule;
|
|
|
|
namespace YLErp
|
|
{
|
|
public class Program
|
|
{
|
|
static IServiceProvider ServiceProvider;
|
|
|
|
[ModuleInitializer]
|
|
internal static void M1()
|
|
{
|
|
Console.WriteLine("version--" + AppManager.Version);
|
|
|
|
var logger = NLog.LogManager.Setup().GetCurrentClassLogger();
|
|
|
|
logger.Debug("init main");
|
|
|
|
IConfiguration configuration = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();
|
|
|
|
var services = new ServiceCollection();
|
|
|
|
YLServiceLocator.SetServiceCollection(services);
|
|
|
|
AppManager.Initialize(YLErp.Enums.SubSystemName.UnitTest, configuration);
|
|
|
|
DataCacheManager.UpdateOnce();
|
|
|
|
services.AddHttpClient("")
|
|
.ConfigurePrimaryHttpMessageHandler(messageHandler =>
|
|
{
|
|
var handler = new HttpClientHandler();
|
|
if (handler.SupportsAutomaticDecompression)
|
|
{
|
|
handler.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
|
|
}
|
|
return handler;
|
|
});
|
|
|
|
ServiceProvider = services.BuildServiceProvider();
|
|
|
|
OtcAppContext.Initialize(s =>
|
|
{
|
|
var s2 = s.Trim('/').Replace("/", "\\");
|
|
return @"d:\\" + s2;
|
|
});
|
|
}
|
|
|
|
public static T GetService<T>()
|
|
{
|
|
return ServiceProvider.GetService<T>();
|
|
}
|
|
}
|
|
}
|