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


C# IInjector.InstantiateUnmapped方法代码示例

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


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

示例1: Approve

		public static bool Approve(IInjector injector, IEnumerable<object> guards)
		{
			object guardInstance;

			foreach (object guard in guards)
			{
				if (guard is Func<bool>)
				{
					if ((guard as Func<bool>)())
						continue;
					return false;
				}
				if (guard is Type)
				{
					if (injector != null)
						guardInstance = injector.InstantiateUnmapped(guard as Type);
					else
						guardInstance = Activator.CreateInstance(guard as Type);
				}
				else
					guardInstance = guard;

				MethodInfo approveMethod = guardInstance.GetType().GetMethod("Approve");
				if (approveMethod != null)
				{
					if ((bool)approveMethod.Invoke (guardInstance, null) == false)
						return false;
				}
				else
				{
					throw(new Exception (String.Format("Guard {0} is not a valid guard. It doesn't have the method 'Approve'", guardInstance)));
				}
			}
			return true;
		}
开发者ID:mikecann,项目名称:robotlegs-sharp-framework,代码行数:35,代码来源:Guards.cs

示例2: Apply

		public static void Apply(IInjector injector, IEnumerable<object> hooks)
		{
			object hookInstance;

			foreach (object hook in hooks)
			{
				if (hook is Action)
				{
					(hook as Action)();
					continue;
				}
				if (hook is Type)
				{
					if (injector != null)
						hookInstance = injector.InstantiateUnmapped(hook as Type);
					else
						hookInstance = Activator.CreateInstance(hook as Type);
				}
				else
					hookInstance = hook;

				MethodInfo hookMethod = hookInstance.GetType().GetMethod("Hook");
				if (hookMethod != null)
					hookMethod.Invoke (hookInstance, null);
				else
					throw new Exception ("Invalid hook to apply");
			}
		}
开发者ID:mikecann,项目名称:robotlegs-sharp-framework,代码行数:28,代码来源:Hooks.cs

示例3: Process

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

		public void Process(object view, Type type, IInjector injector)
 		{
			if (_createdMediatorsByView.ContainsKey(view))
			{
				return;
			}
			object mediator = injector.InstantiateUnmapped(_mediatorClass);
			_createdMediatorsByView.Add(view, mediator);
			InitializeMediator(view, mediator);
 		}
开发者ID:mikecann,项目名称:robotlegs-sharp-framework,代码行数:14,代码来源:MediatorCreator.cs


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