using Autofac; using Microsoft.AspNetCore.Http; using Serilog; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DW5S.Repostory { public static class IocContainer { public static void Init(ILifetimeScope container) { Container = container; Logger=GetService(); } private static ILifetimeScope Container; public static ILogger Logger { get; private set; } public static IUnitOfWork UnitOfWork { get { return GetService(); } } public static T GetService() where T : class { var scop = Container.BeginLifetimeScope(); return scop.Resolve(); } public static T GetService(object parameter) where T : class { var scop = Container.BeginLifetimeScope(); return scop.Resolve( new TypedParameter(parameter.GetType(), parameter)); } } }