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


C# IInjector.GetNamedInstance方法代码示例

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


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

示例1: SerializeAppArgsToBytes

        internal byte[] SerializeAppArgsToBytes(AppParameters appParameters, IInjector paramInjector)
        {
            var avroAppSubmissionParameters = new AvroAppSubmissionParameters
            {
                tcpBeginPort = paramInjector.GetNamedInstance<TcpPortRangeStart, int>(),
                tcpRangeCount = paramInjector.GetNamedInstance<TcpPortRangeCount, int>(),
                tcpTryCount = paramInjector.GetNamedInstance<TcpPortRangeTryCount, int>()
            };

            var avroYarnAppSubmissionParameters = new AvroYarnAppSubmissionParameters
            {
                sharedAppSubmissionParameters = avroAppSubmissionParameters,
                driverRecoveryTimeout = paramInjector.GetNamedInstance<DriverBridgeConfigurationOptions.DriverRestartEvaluatorRecoverySeconds, int>()
            };

            return AvroJsonSerializer<AvroYarnAppSubmissionParameters>.ToBytes(avroYarnAppSubmissionParameters);
        }
开发者ID:beomyeol,项目名称:reef,代码行数:17,代码来源:YarnREEFParamSerializer.cs

示例2: ContextRuntime

 /// <summary>
 /// Create a new ContextRuntime.
 /// </summary>
 /// <param name="serviceInjector"></param>
 /// <param name="contextConfiguration">the Configuration for this context.</param>
 /// <param name="parentContext"></param>
 public ContextRuntime(
         IInjector serviceInjector,
         IConfiguration contextConfiguration,
         Optional<ContextRuntime> parentContext)
 {
     _serviceInjector = serviceInjector;
     _injectedServices = Optional<ISet<object>>.Of(serviceInjector.GetNamedInstance<ServicesSet, ISet<object>>());
     _contextInjector = serviceInjector.ForkInjector(contextConfiguration);
     _contextLifeCycle = _contextInjector.GetInstance<ContextLifeCycle>();
     _parentContext = parentContext;
     _contextLifeCycle.Start();
 }
开发者ID:zerg-junior,项目名称:incubator-reef,代码行数:18,代码来源:ContextRuntime.cs

示例3: RootContextLauncher

 private RootContextLauncher(
     IConfiguration contextConfiguration,
     IConfiguration rootServiceConfig,
     Optional<IConfiguration> rootTaskConfig,
     IInjector injector)
 {
     _rootContextConfiguration = contextConfiguration;
     _rootServiceInjector = injector.ForkInjector(rootServiceConfig);
     Id = _rootServiceInjector
         .ForkInjector(contextConfiguration)
         .GetNamedInstance<ContextConfigurationOptions.ContextIdentifier, string>();
     _services = _rootServiceInjector.GetNamedInstance<ServicesSet, ISet<object>>();
     Logger.Log(Level.Verbose, string.Format(CultureInfo.InvariantCulture, "injected service(s)"));
     RootTaskConfig = rootTaskConfig;
 }
开发者ID:beomyeol,项目名称:reef,代码行数:15,代码来源:RootContextLauncher.cs

示例4: ContextRuntime

        /// <summary>
        /// Create a new ContextRuntime.
        /// </summary>
        /// <param name="serviceInjector"></param>
        /// <param name="contextConfiguration">the Configuration for this context.</param>
        /// <param name="parentContext"></param>
        public ContextRuntime(
                IInjector serviceInjector,
                IConfiguration contextConfiguration,
                Optional<ContextRuntime> parentContext)
        {
            _serviceInjector = serviceInjector;

            // Note that for Service objects and handlers, we are not merging them into a separate
            // class (e.g. ServiceContainer) due to the inability to allow service stacking if an instance 
            // of such a class were to be materialized. i.e. if a ServiceContainer object were initialized
            // and a child ServiceConfiguration is submitted, when the child service injector tries to
            // get the relevant handlers and services set, it will get the same set of handlers as
            // previously instantiated by the parent injector, and thus will not allow the stacking
            // of ServiceConfigurations.
            _injectedServices = serviceInjector.GetNamedInstance<ServicesSet, ISet<object>>();

            _serviceContextStartHandlers = 
                serviceInjector.GetNamedInstance<ContextConfigurationOptions.StartHandlers, ISet<IObserver<IContextStart>>>();

            _serviceContextStopHandlers = 
                serviceInjector.GetNamedInstance<ContextConfigurationOptions.StopHandlers, ISet<IObserver<IContextStop>>>();

            _serviceTaskStartHandlers = 
                serviceInjector.GetNamedInstance<TaskConfigurationOptions.StartHandlers, ISet<IObserver<ITaskStart>>>();

            _serviceTaskStopHandlers = 
                serviceInjector.GetNamedInstance<TaskConfigurationOptions.StopHandlers, ISet<IObserver<ITaskStop>>>();

            _contextInjector = serviceInjector.ForkInjector(contextConfiguration);
            _contextLifeCycle = _contextInjector.GetInstance<ContextLifeCycle>();
            _parentContext = parentContext;

            try
            {
                _contextLifeCycle.Start();
            }
            catch (Exception e)
            {
                const string message = "Encountered Exception in ContextStartHandler.";
                if (ParentContext.IsPresent())
                {
                    throw new ContextStartHandlerException(
                        Id, Optional<string>.Of(ParentContext.Value.Id), message, e);
                }
                
                throw new ContextStartHandlerException(Id, Optional<string>.Empty(), message, e);
            }
        }
开发者ID:beomyeol,项目名称:reef,代码行数:54,代码来源:ContextRuntime.cs

示例5: GetDeprecatedTaskRuntime

        private TaskRuntime GetDeprecatedTaskRuntime(
            IInjector taskInjector, string contextId, IConfiguration taskConfiguration, IHeartBeatManager heartBeatManager)
        {
            var taskId = string.Empty;
            try
            {
                taskId = taskInjector.GetNamedInstance<TaskConfigurationOptions.Identifier, string>();
            }
            catch (Exception e)
            {
                var ex = new TaskClientCodeException(string.Empty, Id, "Unable to instantiate the new task", e);
                Utilities.Diagnostics.Exceptions.CaughtAndThrow(ex, Level.Error, "Cannot get instance of Task ID: " + e.StackTrace, LOGGER);
            }

            LOGGER.Log(Level.Info, "Trying to inject task with configuration" + taskConfiguration);

            return new TaskRuntime(taskInjector, contextId, taskId, heartBeatManager);
        }
开发者ID:kumbhare,项目名称:reef,代码行数:18,代码来源:ContextRuntime.cs


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