- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
如果我有一个类,其中的 ctor 设置为像这样的多重注入(inject):
public Shogun(IEnumerable<IWeapon> allWeapons)
{
this.allWeapons = allWeapons;
}
绑定(bind)设置如下:
Bind<IWeapon>().To<Sword>();
Bind<IWeapon>().To<Dagger>().WhenInjectedInto<Shogun>();
那么我希望 build 幕府将军时两种武器都已注入(inject)?但事实并非如此 - 它只会获得 Dagger 。
如果我像这样添加进一步的绑定(bind):
Bind<IWeapon>().To<Sword>();
Bind<IWeapon>().To<Dagger>().WhenInjectedInto<Shogun>();
Bind<IWeapon>().To<Shuriken>().WhenInjectedInto<Shogun>();
然后幕府将军得到了 Dagger 和手里剑。 WhenInjectedInto<T>()
看起来它应该只约束它所应用的绑定(bind)而不影响其他绑定(bind)。我发现这种行为非常具有误导性。
谁能解释一下这里发生了什么?
最佳答案
这是一个错误 - GetAll will not return all instances in case conditional and unconditional bindings are mixed .
在版本 Version 2.4.0.0 中修复
关于c# - Ninject multi-injection 并没有我想象的那么贪心!怎么会?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7297342/
我正在使用 PHP Imagick 来处理图像。 我有两个用例:“调整大小”和“裁剪”。 在“调整大小”中,如果原始图像的尺寸小于给定的宽度和高度,我不希望 Imagick 将其放大,而是希望它简单地
当尝试从 PHP 进行简单的转换时,我收到此错误: exception 'ImagickException' with message 'wand contains no images `Magick
我想了解如何从动画 GIF 中删除帧。 目前我正在尝试这个(作为测试): $count = 1; foreach ($_im AS $frame) { if ($count > 1) { $f
我正在处理 Sylius 1.5 项目,在我的本地环境中一切正常,但是在部署到我的开发环境时,我在过滤图像上遇到错误(使用 liip 想象过滤器)。 该环境由一个运行 sylius 的 docker
我是一名优秀的程序员,十分优秀!