1234567891011121314151617181920212223242526272829303132333435363738 |
- 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<ILogger>();
- }
- private static ILifetimeScope Container;
- public static ILogger Logger { get; private set; }
- public static IUnitOfWork UnitOfWork
- {
- get
- {
- return GetService<IUnitOfWork>();
- }
- }
- public static T GetService<T>() where T : class
- {
- var scop = Container.BeginLifetimeScope();
- return scop.Resolve<T>();
- //return Container.Resolve<T>();
- }
- }
- }
|