本文整理汇总了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;
}
示例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");
}
}
示例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);
}