using Autofac; namespace CQRS_Simple.Infrastructure { public interface IIocManager { ILifetimeScope AutofacContainer { get; set; } TService GetInstance(); } public class IocManager : IIocManager { public IocManager(ILifetimeScope container) { AutofacContainer = container; } /// /// Autofac容器 /// public ILifetimeScope AutofacContainer { get; set; } public TService GetInstance() { return AutofacContainer.Resolve(); } } }