using CZFW.Core; using CZFW.Framework; using CZFW.Framework.Logic; using CZFW.Framework.Model; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using System; using System.Collections.Generic; using System.IO; using System.Text; namespace CZKJ.GBRS2.Test { public class TestBase { public TestBase() { ServiceProvider = TestDI.ServiceProvider; } public ServiceProvider ServiceProvider { get; set; } public TInterface GetService() { return ServiceProvider.GetService(); } } public static class TestDI { private static ServiceProvider serviceProvider; public static ServiceProvider ServiceProvider { get { if (serviceProvider == null) { IServiceCollection service = new ServiceCollection(); service.ConfigServies(); service.AddLogging(); service.ConfigureFrameworkServices(); serviceProvider = service.BuildServiceProvider(); CZHttpContext.ServiceProvider = serviceProvider; var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json"); ConfigHelper.Configs = builder.Build(); } return serviceProvider; } } } }