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


C# IInjector.GetInstance方法代码示例

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


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

示例1: before

		public void before()
		{
			context = new Context();
			injector = context.injector;
			injector.Map<IDirectCommandMap>().ToType<DirectCommandMap>();
			subject = injector.GetInstance<IDirectCommandMap>() as DirectCommandMap;
		}
开发者ID:mikecann,项目名称:robotlegs-sharp-framework,代码行数:7,代码来源:DirectCommandMapTest.cs

示例2: MediatorFactory

		/*============================================================================*/
		/* Constructor                                                                */
		/*============================================================================*/

		public MediatorFactory (IInjector injector)
		{
			_injector = injector;
			_manager = injector.HasMapping (typeof(IMediatorManager)) 
				? injector.GetInstance (typeof(IMediatorManager)) as IMediatorManager
				: new MediatorManager ();
			_manager.ViewRemoved += RemoveMediators;
		}
开发者ID:mikecann,项目名称:robotlegs-sharp-framework,代码行数:12,代码来源:MediatorFactory.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: Process

		/*============================================================================*/
		/* Public Functions                                                           */
		/*============================================================================*/

		public void Process(Object view, Type type, IInjector injector)
		{
			foreach (String fieldName in _fieldTypesByName.Keys)
			{
				FieldInfo field = view.GetType().GetField(fieldName);
				if (field != null)
				{
					object valueToInject = injector.GetInstance(_fieldTypesByName[fieldName]);
					if (valueToInject != null)
					{
						field.SetValue(view, valueToInject);
					}
				}
			}
		}
开发者ID:mikecann,项目名称:robotlegs-sharp-framework,代码行数:19,代码来源:FastPropertyInjector.cs

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