本文整理汇总了C#中ILifetimeScope.TryResolve方法的典型用法代码示例。如果您正苦于以下问题:C# ILifetimeScope.TryResolve方法的具体用法?C# ILifetimeScope.TryResolve怎么用?C# ILifetimeScope.TryResolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILifetimeScope
的用法示例。
在下文中一共展示了ILifetimeScope.TryResolve方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetModule
protected override INancyModule GetModule(ILifetimeScope container, Type moduleType)
{
RequiresNotNull(container);
RequiresNotNull(moduleType);
object module;
return container.TryResolve(moduleType, out module) ? (INancyModule) module : null;
}
示例2: BaseCustomActionsManager
/// <summary>
/// Initialises a new instance of the BaseCustomActionsManager class
/// using the specified extra suffix and the assembly of the actual type of this class.
/// </summary>
protected BaseCustomActionsManager(ILifetimeScope container, string extraSuffix, IEnumerable<ImplementorAssembly> assemblies)
{
if (container == null) { throw new ArgumentNullException("container"); }
if (assemblies == null) { throw new ArgumentNullException("assemblies"); }
_container = container;
// Each assembly only once. Thus assemblies will be registered by modules throug Autofac it cannot be guaranteed that this will happen only once per assembly.
_assemblies = assemblies.Distinct().ToList();
ExtraSuffix = extraSuffix;
ImplementationAssemblyName = this.GetType().Assembly.FullName;
container.TryResolve<IAssetsManager>(out _assetsMgr);
cfg = container.Resolve<ZetboxConfig>();
}
示例3: CreateTask
private ITask CreateTask(ILifetimeScope timerScope)
{
ITask task = null;
if (this.Enabled)
{
var type2 = System.Type.GetType(this.Type);
if (type2 != null)
{
object instance;
if (!timerScope.TryResolve(type2, out instance))
{
instance = ResolveUnregistered(timerScope,type2);
}
task = instance as ITask;
}
}
return task;
}