当前位置: 首页>>代码示例>>C#>>正文


C# ILifetimeScope.BeginLifetimeScope方法代码示例

本文整理汇总了C#中ILifetimeScope.BeginLifetimeScope方法的典型用法代码示例。如果您正苦于以下问题:C# ILifetimeScope.BeginLifetimeScope方法的具体用法?C# ILifetimeScope.BeginLifetimeScope怎么用?C# ILifetimeScope.BeginLifetimeScope使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ILifetimeScope的用法示例。


在下文中一共展示了ILifetimeScope.BeginLifetimeScope方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PingHub

        public PingHub(ILifetimeScope lifetimeScope)
        {
            // Create a lifetime scope for this hub instance.
            _hubLifetimeScope = lifetimeScope.BeginLifetimeScope();

            // Resolve the dependencies from the hub lifetime scope (unfortunately, service locator style).
            _bar = _hubLifetimeScope.Resolve<IBar>();
            _foo = _hubLifetimeScope.Resolve<IFoo>();
        }
开发者ID:FukKwang,项目名称:SignalRSamples,代码行数:9,代码来源:PingHub.cs

示例2: NotificationHub

        public NotificationHub(ILifetimeScope scope)
            : base()
        {
            var lifetimeScope = scope.BeginLifetimeScope("AutofacWebRequest");

            this.gameService = lifetimeScope.Resolve<IGameService>();
            this.unitOfWork = lifetimeScope.Resolve<IUnitOfWork>();
            this.userManager = lifetimeScope.Resolve<UserManager<User>>();
        }
开发者ID:cschleiden,项目名称:imperaplus-backend,代码行数:9,代码来源:NotificationHub.cs

示例3: SimulateRequest

		private static void SimulateRequest(ILifetimeScope rootLifetimeScope)
		{
			using (var requestLifetimeScope = rootLifetimeScope.BeginLifetimeScope())
			{
				var consumer = requestLifetimeScope.Resolve<ServiceConsumer>();

				Console.WriteLine(consumer.DoSomething());
			}
		}
开发者ID:MrScruffy04,项目名称:Testbed.Autofac,代码行数:9,代码来源:Program.cs

示例4: CommonHub

        public CommonHub(ILifetimeScope lifetimeScope)
        {
            // Create a lifetime scope for the hub.
            _hubLifetimeScope = lifetimeScope.BeginLifetimeScope();

            // Resolve dependencies from the hub lifetime scope
            _documentService = _hubLifetimeScope.Resolve<IDocumentsService>(); // singleton
            _tableService = _hubLifetimeScope.Resolve<ITableService>(); // singleton
            _counterService = _hubLifetimeScope.Resolve<IDistributedCounter>(); // singleton
        }
开发者ID:Enttoi,项目名称:enttoi-api,代码行数:10,代码来源:CommonHub.cs

示例5: InitializeLifetimeScope

 static ILifetimeScope InitializeLifetimeScope(Action<ContainerBuilder> configurationAction, ILifetimeScope container)
 {
     return (configurationAction == null)
         ? container.BeginLifetimeScope(HttpRequestTag)
         //, mp =>
         //{
         //    mp.RegisterHttpRequestMessage(GlobalConfiguration.Configuration); 
         //  //  mp.Update(container.ComponentRegistry);
         //})
         : container.BeginLifetimeScope(HttpRequestTag, configurationAction);
 }
开发者ID:surifoll,项目名称:git-test,代码行数:11,代码来源:AutofacRequestLifetimeHttpModule.cs

示例6: UseAutofacMiddleware

        public static IAppBuilder UseAutofacMiddleware(this IAppBuilder app, ILifetimeScope container)
        {
            app.Use(async (context, next) =>
            {
                using (var lifetimeScope = container.BeginLifetimeScope(Constants.LifetimeScopeTag,
                    b => b.RegisterInstance(context).As<IOwinContext>()))
                {
                    context.Set(Constants.OwinLifetimeScopeKey, lifetimeScope);
                    await next();
                }
            });

            return UseMiddlewareFromContainer(app, container);
        }
开发者ID:wjt0818,项目名称:Autofac,代码行数:14,代码来源:AutofacAppBuilderExtensions.cs

示例7: DispatchCommit

        private static void DispatchCommit(ILifetimeScope container, Commit commit)
        {
            using (var scope = container.BeginLifetimeScope())
            {
                NanoMessageBus.IPublishMessages publisher = scope.Resolve<NanoMessageBus.IPublishMessages>();

                publisher.Publish(commit.Events.Select(e => e.Body).ToArray());

                // need to complete and dispose the uow to do the actual publishing since
                // the IHandleUnitOfWork is registered as ExternalyOwned
                using (IHandleUnitOfWork uow = scope.Resolve<IHandleUnitOfWork>())
                {
                    uow.Complete();
                }
            }
        }
开发者ID:james-wu,项目名称:CQRSEventSourcingSample,代码行数:16,代码来源:StorageConfigModule.cs

示例8: UseAutofacMiddleware

        public static IAppBuilder UseAutofacMiddleware(this IAppBuilder app, ILifetimeScope container)
        {
            if (app == null) throw new ArgumentNullException("app");

            if (app.Properties.ContainsKey(MiddlewareRegisteredKey)) return app;

            app.Use(async (context, next) =>
            {
                using (var lifetimeScope = container.BeginLifetimeScope(Constants.LifetimeScopeTag,
                    b => b.RegisterInstance(context).As<IOwinContext>()))
                {
                    context.Set(Constants.OwinLifetimeScopeKey, lifetimeScope);
                    await next();
                }
            });

            UseMiddlewareFromContainer(app, container);

            app.Properties.Add(MiddlewareRegisteredKey, true);

            return app;
        }
开发者ID:najunuoyan,项目名称:Autofac,代码行数:22,代码来源:AutofacAppBuilderExtensions.cs

示例9: AppCore

        /// <summary>
        /// Создать область видимости приложения
        /// </summary>
        /// <param name="container">Контейнер области видимости приложения</param>
        public AppCore(ILifetimeScope container) : base()
        {
            _rootScope = container;
            
            Scope = _rootScope.BeginLifetimeScope(b =>
                {
                    b.RegisterType<Config>()
                        .AsSelf()
                        .SingleInstance();

                    b.RegisterInstance(this)
                        .AsSelf()
                        .SingleInstance();

                    b.Register(c => this.BeginScope())
                        .As<IAppScope>()
                        .AsSelf();

                    b.RegisterModule<EmitImplementerModule>();
                });
            
            Instance = this;
        }
开发者ID:holinov,项目名称:Zen.Core,代码行数:27,代码来源:AppCore.cs

示例10: UseAutofacMiddleware

        public static IAppBuilder UseAutofacMiddleware(this IAppBuilder app, ILifetimeScope container)
        {
            if (app == null) throw new ArgumentNullException("app");

            // idsvr : remove these guards so that multiple copies of middleware can be registered
            //if (app.Properties.ContainsKey(MiddlewareRegisteredKey)) return app;
            
            app.Use(async (context, next) =>
            {
                using (var lifetimeScope = container.BeginLifetimeScope(MatchingScopeLifetimeTags.RequestLifetimeScopeTag,
                    b => b.RegisterInstance(context).As<IOwinContext>()))
                {
                    context.Set(Constants.OwinLifetimeScopeKey, lifetimeScope);
                    await next();
                }
            });

            UseMiddlewareFromContainer(app, container);

            // idsvr : remove these guards so that multiple copies of middleware can be registered
            //app.Properties.Add(MiddlewareRegisteredKey, true);

            return app;
        }
开发者ID:ridopark,项目名称:IdentityServer3,代码行数:24,代码来源:AutofacAppBuilderExtensions.cs

示例11: Setup

 public void Setup()
 {
     _hostContainer = new ContainerBuilder().Build().BeginLifetimeScope(DreamContainerScope.Host);
     _serviceContainer = _hostContainer.BeginLifetimeScope(DreamContainerScope.Service);
     _requestContainer = _serviceContainer.BeginLifetimeScope(DreamContainerScope.Request);
 }
开发者ID:aaronmars,项目名称:DReAM,代码行数:6,代码来源:XDocAutofacContainerConfiguratorTests.cs

示例12: InitializeLifetimeScope

 static ILifetimeScope InitializeLifetimeScope(Action<ContainerBuilder> configurationAction, ILifetimeScope container)
 {
     return (configurationAction == null) ? container.BeginLifetimeScope(HttpRequestTag) : container.BeginLifetimeScope(HttpRequestTag, configurationAction);
 }
开发者ID:revolutionaryarts,项目名称:wewillgather,代码行数:4,代码来源:AutofacRequestLifetimeHttpModule.cs

示例13: BeginLifetimeScope

 public static ILifetimeScope BeginLifetimeScope(ILifetimeScope scope, IMessageActivity message)
 {
     var inner = scope.BeginLifetimeScope(LifetimeScopeTag);
     inner.Resolve<IMessageActivity>(TypedParameter.From(message));
     return inner;
 }
开发者ID:CHENShuang1994,项目名称:BotBuilder,代码行数:6,代码来源:DialogModule.cs

示例14: AutofacScope

 protected AutofacScope(ILifetimeScope scope)
 {
     _scope = scope.BeginLifetimeScope();
 }
开发者ID:keskival,项目名称:2,代码行数:4,代码来源:AutofacScope.cs

示例15: ContentScope

 public ContentScope(Type type, object key, ILifetimeScope parentScope, params Parameter[] parameters)
 {
     scope = parentScope.BeginLifetimeScope();
     Content = scope.ResolveKeyed(key, type, parameters) as IContentViewModel;
 }
开发者ID:Corne,项目名称:WPFTemplate,代码行数:5,代码来源:ContentScope.cs


注:本文中的ILifetimeScope.BeginLifetimeScope方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。