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.
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace djy_IsfApi
|
|
|
|
|
{
|
|
|
|
|
/// <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>();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|