本文整理汇总了C#中TinyIoCContainer.CanResolve方法的典型用法代码示例。如果您正苦于以下问题:C# TinyIoCContainer.CanResolve方法的具体用法?C# TinyIoCContainer.CanResolve怎么用?C# TinyIoCContainer.CanResolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TinyIoCContainer
的用法示例。
在下文中一共展示了TinyIoCContainer.CanResolve方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateContainerForAssembly
public TinyIoCContainer CreateContainerForAssembly(Assembly assembly)
{
IPackageManagerModule module = CreateModule(assembly);
Type packageManagerType = module.PackageManagerType;
Debug.Assert(PackageManagerType.IsAssignableFrom(packageManagerType));
var container = new TinyIoCContainer();
module.RegisterDependencies(container);
if (container.CanResolve<IPackageManager>())
{
throw new ConfigurationException("Package Manager should not be manually configured in the dependency injection container");
}
container.Register(PackageManagerType, packageManagerType);
container.Register<ILogger>((c, p) => new Logger(new Context(packageManagerType.ToString()), _log));
container.Register<IShellCommandRunner, ShellCommandRunner>();
return container;
}
示例2: registerDefaultTypes
static void registerDefaultTypes(TinyIoCContainer kernel)
{
var toRegister = new[] {
new { Interface = typeof(IProcessFactory), Impl = typeof(DefaultProcessFactory) },
new { Interface = typeof(IErrorViewModel), Impl = typeof(ErrorViewModel) },
new { Interface = typeof(IWelcomeViewModel), Impl = typeof(WelcomeViewModel) },
new { Interface = typeof(IInstallingViewModel), Impl = typeof(InstallingViewModel) },
new { Interface = typeof(IUninstallingViewModel), Impl = typeof(UninstallingViewModel) },
new { Interface = typeof(IViewFor<ErrorViewModel>), Impl = typeof(ErrorView) },
new { Interface = typeof(IViewFor<WelcomeViewModel>), Impl = typeof(WelcomeView) },
new { Interface = typeof(IViewFor<InstallingViewModel>), Impl = typeof(InstallingView) },
new { Interface = typeof(IViewFor<UninstallingViewModel>), Impl = typeof(UninstallingView) },
};
foreach (var pair in toRegister.Where(pair => !kernel.CanResolve(pair.Interface))) {
kernel.Register(pair.Interface, pair.Impl);
}
}