private static IService ResolveFromScope(IServiceResolver resolver)
 {
     using (var scope = resolver.CreateScope())
     {
         return(scope.Resolve <IService>());
     }
 }
Exemple #2
0
 /// <summary>
 /// 开始作用域
 /// </summary>
 /// <param name="context">上下文</param>
 public override JobActivatorScope BeginScope(JobActivatorContext context)
 {
     if (_serviceResolver == null)
     {
         return(new MsdiScope(_serviceProvider.CreateScope()));
     }
     return(new AspectCoreScope(_serviceResolver.CreateScope()));
 }
 public IServiceScope CreateScope()
 {
     return(new ServiceScope(_serviceResolver.CreateScope()));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PluginServiceScope"/> class.
 /// </summary>
 /// <param name="serviceProvider">The service provider.</param>
 /// <param name="cache">The cache.</param>
 /// <param name="aspectConfiguration">The aspect configuration.</param>
 public PluginServiceScope(IServiceResolver serviceProvider, PluginSerivceTypeCache cache, AspectConfiguration aspectConfiguration)
 {
     this.serviceProvider     = serviceProvider.CreateScope();
     this.cache               = cache;
     this.aspectConfiguration = aspectConfiguration;
 }