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


C# IInjector.ForkInjector方法代码示例

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


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

示例1: 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)
        {
            ContextConfiguration config = contextConfiguration as ContextConfiguration;
            if (config == null)
            {
                var e = new ArgumentException("contextConfiguration is not of type ContextConfiguration");
                Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
            }
            _contextLifeCycle = new ContextLifeCycle(config.Id);
            _serviceInjector = serviceInjector;
            _parentContext = parentContext;
            try
            {
                _contextInjector = serviceInjector.ForkInjector();
            }
            catch (Exception e)
            {
                Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);

                Optional<string> parentId = ParentContext.IsPresent() ?
                    Optional<string>.Of(ParentContext.Value.Id) :
                    Optional<string>.Empty();
                ContextClientCodeException ex = new ContextClientCodeException(ContextClientCodeException.GetId(contextConfiguration), parentId, "Unable to spawn context", e);
                
                Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
            }
            // Trigger the context start events on contextInjector.
            _contextLifeCycle.Start();
        }
开发者ID:kijungs,项目名称:incubator-reef,代码行数:38,代码来源:ContextRuntime.cs

示例2: GroupCommClient

        public GroupCommClient(
            [Parameter(typeof(GroupCommConfigurationOptions.SerializedGroupConfigs))] ISet<string> groupConfigs,
            [Parameter(typeof(TaskConfigurationOptions.Identifier))] string taskId,
            StreamingNetworkService<GeneralGroupCommunicationMessage> networkService,
            AvroConfigurationSerializer configSerializer,
            IInjector injector)
        {
            _commGroups = new Dictionary<string, ICommunicationGroupClientInternal>();
            _networkService = networkService;

            foreach (string serializedGroupConfig in groupConfigs)
            {
                IConfiguration groupConfig = configSerializer.FromString(serializedGroupConfig);
                IInjector groupInjector = injector.ForkInjector(groupConfig);
                var commGroupClient = (ICommunicationGroupClientInternal)groupInjector.GetInstance<ICommunicationGroupClient>();
                _commGroups[commGroupClient.GroupName] = commGroupClient;
            }

            networkService.Register(new StringIdentifier(taskId));

            foreach (var group in _commGroups.Values)
            {
               group.WaitingForRegistration();
            }
        }
开发者ID:NurimOnsemiro,项目名称:reef,代码行数:25,代码来源:GroupCommClient.cs

示例3: 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;
     _contextInjector = serviceInjector.ForkInjector(contextConfiguration);
     _contextLifeCycle = _contextInjector.GetInstance<ContextLifeCycle>();
     _parentContext = parentContext;
     _contextLifeCycle.Start();
 }
开发者ID:LastOne817,项目名称:reef,代码行数:17,代码来源:ContextRuntime.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;
     _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

示例5: 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

示例6: GroupCommClient

        private GroupCommClient(
            [Parameter(typeof(GroupCommConfigurationOptions.SerializedGroupConfigs))] ISet<string> groupConfigs,
            [Parameter(typeof(TaskConfigurationOptions.Identifier))] string taskId,
            NetworkService<GroupCommunicationMessage> networkService,
            AvroConfigurationSerializer configSerializer,
            IInjector injector)
        {
            _commGroups = new Dictionary<string, ICommunicationGroupClient>();
            _networkService = networkService;
            networkService.Register(new StringIdentifier(taskId));

            foreach (string serializedGroupConfig in groupConfigs)
            {
                IConfiguration groupConfig = configSerializer.FromString(serializedGroupConfig);
                IInjector groupInjector = injector.ForkInjector(groupConfig);
                ICommunicationGroupClient commGroupClient = groupInjector.GetInstance<ICommunicationGroupClient>();
                _commGroups[commGroupClient.GroupName] = commGroupClient;
            }
        }
开发者ID:kijungs,项目名称:incubator-reef,代码行数:19,代码来源:GroupCommClient.cs

示例7: ForksInjectorInConstructor

 public ForksInjectorInConstructor(IInjector i)
 {
     ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder(new string[] { @"Org.Apache.REEF.Tang.Examples" });
     //cb.BindImplementation(Number.class, typeof(Int32));
     i.ForkInjector(cb.Build());
 }
开发者ID:kijungs,项目名称:incubator-reef,代码行数:6,代码来源:ForksInjectorInConstructor.cs

示例8: EvaluatorSettings

        private EvaluatorSettings(
            [Parameter(typeof(ApplicationIdentifier))] string applicationId,
            [Parameter(typeof(EvaluatorIdentifier))] string evaluatorId,
            [Parameter(typeof(EvaluatorHeartbeatPeriodInMs))] int heartbeatPeriodInMs,
            [Parameter(typeof(HeartbeatMaxRetry))] int maxHeartbeatRetries,
            [Parameter(typeof(RootContextConfiguration))] string rootContextConfigString,
            AvroConfigurationSerializer serializer,
            RuntimeClock clock,
            IRemoteManagerFactory remoteManagerFactory,
            REEFMessageCodec reefMessageCodec,
            IInjector injector,
            INameClient nameClient)
        {
            _serializer = serializer;
            _injector = injector;
            _applicationId = applicationId;
            _evaluatorId = evaluatorId;
            _heartBeatPeriodInMs = heartbeatPeriodInMs;
            _maxHeartbeatRetries = maxHeartbeatRetries;
            _clock = clock;

            if (string.IsNullOrWhiteSpace(rootContextConfigString))
            {
                Utilities.Diagnostics.Exceptions.Throw(
                    new ArgumentException("empty or null rootContextConfigString"), Logger);
            }
            _rootContextConfig = _serializer.FromString(rootContextConfigString);

            try
            {
                _rootContextId = injector.ForkInjector(_rootContextConfig).GetNamedInstance<ContextConfigurationOptions.ContextIdentifier, string>();
            }
            catch (InjectionException)
            {
                Logger.Log(Level.Info, "Using deprecated ContextConfiguration.");

                // TODO[JIRA REEF-1167]: Remove this catch.
                var deprecatedContextConfig = new Context.ContextConfiguration(rootContextConfigString);
                _rootContextConfig = deprecatedContextConfig;
                _rootContextId = deprecatedContextConfig.Id;
            }

            _rootTaskConfiguration = CreateTaskConfiguration();
            _rootServiceConfiguration = CreateRootServiceConfiguration();

            _remoteManager = remoteManagerFactory.GetInstance(reefMessageCodec);
            _operationState = EvaluatorOperationState.OPERATIONAL;
            _nameClient = nameClient;
        }
开发者ID:kumbhare,项目名称:reef,代码行数:49,代码来源:EvaluatorSettings.cs

示例9: ForksInjectorInConstructor

 public ForksInjectorInConstructor(IInjector i)
 {
     ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder(new string[] { @"Com.Microsoft.Tang.Examples" });
     //cb.BindImplementation(Number.class, typeof(Int32));
     i.ForkInjector(new IConfiguration[] { cb.Build() });
 }
开发者ID:kyungtaak,项目名称:TANG,代码行数:6,代码来源:ForksInjectorInConstructor.cs

示例10: 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


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