public ActionResult Index() { using (var ctx = _factory.CreateScopeResolver()) { var singleton2 = _container.GetService <ISingleton>(); var scoped2 = _container.GetService <IChildScoped>(); var scoped4 = (IChildScoped)HttpContext.GetService(typeof(IChildScoped)); var scoped3 = (IChildScoped)_provider.GetService(typeof(IChildScoped)); var scoped5 = ctx.Resolver.GetService <IChildScoped>(); //var scoped4 = (IChildScoped)HttpContext.RequestServices.GetService(typeof(IChildScoped)); //var scoped5 = ctx.Resolver.GetService<IChildScoped>(); //_temp.Scoped;//(IChildScoped) HttpContext.RequestServices.GetService(typeof(IChildScoped)); var transient2 = _container.GetService <ITransient>(); var list = new List <string> { string.Format("Singleton 1:{0} Singleton 2:{1}", _singleton.Id, singleton2.Id), string.Format("Scoped 1:{0} Scoped 2:{1}", _scoped.Id, scoped2.Id), string.Format("Scoped 3:{0} Scoped 4:{1}", scoped3.Id, scoped4?.Id), string.Format("Scoped 5:{0} Scoped 6:{1}", scoped5.Id, _temp6.Scoped.Id), string.Format("Transient 1:{0} Transient 2:{1}", _transient.Id, transient2.Id) }; ViewData["testMsg"] = list; return(View()); } }
public override IMethodInterceptor GetInterceptor(IIocResolver resolver) { var plusOne = resolver.GetService <PlusOneInterceptor>(); plusOne.Order = Order; return(plusOne); }
public override IMethodInterceptor GetInterceptor(IIocResolver resolver) { var empty = resolver.GetService <EmptyInterceptor>(); empty.Order = Order; return(empty); }
public IUnitOfWorkCompleteHandle Begin() { var uow = _resolver.GetService <IUnitOfWork>(); uow.Disposed += Uow_Disposed; uow.Begin(); _provider.Current = uow; return(uow); }
public EfCoreDbContext Resolve(string connectionString = null) { var dbContextConstructorArgs = new { options = DbContextConfigurer.Instance.GetDbContextOptions(connectionString) }; return(_resolver.GetService <EfCoreDbContext>(dbContextConstructorArgs)); }
public override IMethodInterceptor GetInterceptor(IIocResolver resolver) { var manager = resolver.GetService <IUnitOfWorkManager>(); return(new UnitOfWorkInterceptor(manager) { RequiresNewTransaction = NestedTransaction, Order = Order }); }
protected IIocResolverScope CreateScope() { var factory = _resolver.GetService <IIocResolverScopeFactory>(); return(factory.CreateScopeResolver()); }
public object GetRequiredService(Type serviceType) { return(_resolver.GetService(serviceType)); }