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


C# IComponentContext.BeginScope方法代码示例

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


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

示例1: EventAutomation

        public EventAutomation(IComponentContext context, EventAutomationSettings settings)
        {
            Guard.NotNull(() => context, context);
            Guard.NotNull(() => settings, settings);

            this.scope = context.BeginScope(c => { });
            // TODO: see how to make this generic and not tied to Autofac somehow?
            ((ComponentContext)scope).Scope.ComponentRegistry.AddRegistrationSource(this);

            this.binding = scope.Resolve<IBindingFactory>()
                .CreateBinding<IObservable<IEventPattern<object, EventArgs>>>(scope, settings.Binding);

            this.binding.Refresh();
            this.subscription = this.binding.Instance.Subscribe(OnEvent);

            if (settings.CommandSettings != null)
                command = new Lazy<ICommandAutomation>(() => settings.CommandSettings.CreateAutomation(scope));
        }
开发者ID:NuPattern,项目名称:CodeFirst,代码行数:18,代码来源:EventAutomation.cs

示例2: InstantiateProduct

        /// <summary>
        /// Simulates runtime behavior.
        /// </summary>
        private static Product InstantiateProduct(IComponentContext context)
        {
            var schema = context.Resolve<IToolkitCatalog>().Toolkits.First().Products.First();

            // User instantiates a product via Solution Builder:
            var product = new Product("MyWebService", typeof(IAmazonWebServices).FullName);
            ComponentMapper.SyncProduct(product, schema);

            var productContext = context.BeginScope(b => b.RegisterInstance(product));
            foreach (var setting in schema.Automations)
            {
                product.AddAutomation(setting.CreateAutomation(productContext));
            }

            return product;
        }
开发者ID:NuPattern,项目名称:CodeFirst,代码行数:19,代码来源:ToolkitBuilderFixture.cs


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