using Microsoft.Extensions.DependencyInjection; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace djy_AmsApi { /// /// Ioc封装 /// public class IOC { /// /// IServiceCollection 对象 /// public static IServiceCollection container { get; set; } /// /// ICo模式实例化 /// /// /// public static T AddServer() { ServiceProvider provider = container.BuildServiceProvider(); return provider.GetService(); } } }