mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-11-10 11:24:45 +08:00
转移.net core 3.1,为.NET 5做准备
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
|
||||
namespace Infrastructure.Extensions.AutofacManager
|
||||
{
|
||||
/// <summary>
|
||||
/// 提供全局静态获取服务的能力。
|
||||
/// <para>例:AutofacContainerModule.GetService<IPathProvider>()</para>
|
||||
/// </summary>
|
||||
public class AutofacContainerModule
|
||||
{
|
||||
static private IServiceProvider _provider;
|
||||
public static void ConfigServiceProvider(IServiceProvider serviceProvider)
|
||||
{
|
||||
_provider = serviceProvider;
|
||||
}
|
||||
public static TService GetService<TService>() where TService:class
|
||||
{
|
||||
Type typeParameterType = typeof(TService);
|
||||
return (TService)_provider.GetService(typeParameterType);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user