You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
742 B
C#

2 years ago
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
2 years ago
namespace djy_Report
2 years ago
{
/// <summary>
/// Ioc封装
/// </summary>
public class IOC
{
/// <summary>
/// IServiceCollection 对象
/// </summary>
public static IServiceCollection container { get; set; }
/// <summary>
/// ICo模式实例化
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public static T AddServer<T>()
{
ServiceProvider provider = container.BuildServiceProvider();
return provider.GetService<T>();
}
}
}