- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
给定:
public interface IFeedOperations : IOperationsWithPreInstalledData
{
...
}
public class FeedOperations : IFeedOperations
{
}
如何为实现 IFeedOperations
的类使用 RegisterType因此 IOperationsWithPreInstalledData
还有吗?
public class FeedsInstaller : IDependencyInstaller
{
public void Install(IDependencyContainer container)
{
container.RegisterType(typeof(IFeedOperations), typeof(FeedOperations));
container.RegisterType(typeof(IOperationsWithPreInstalledData), typeof(FeedOperations));
}
}
当前代码产生以下错误。如果我删除第二个 RegisterType,那么我在调用 container.ResolveAll<IOperationsWithPreInstalledData>()
时不会得到任何结果。 .
Component ...Feeds.FeedOperations could not be registered. There is already a component with that name. Did you want to modify the existing component instead? If not, make sure you specify a unique name.
如果我删除第二个 RegisterType,那么我在调用 container.ResolveAll<IOperationsWithPreInstalledData>()
时不会得到任何结果。 .温莎城堡似乎没有看到实现 IFeedOperations
的类还实现了 IOperationsWithPreInstalledData
.
我如何向 CaSTLe Windsor 注册我的实现类,以便它知道我的类实现了两个接口(interface)——或者更确切地说,我的类可以解析任一接口(interface)。
最佳答案
container.Register(Component.For<IFoo,IBar>().ImplementedBy<FooBar>());
关于c# - 实现多个接口(interface)的类如何使用RegisterType?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14428572/
我目前的情况是,我正在为一些代码编写单元测试,这些代码使用另一个代码库,该代码库使用依赖注入(inject)并提供 UnitContainerExtension 来引导库所需的所有具体类。但是在我的单
我正在跟踪在StackOverflow上找到的示例,一切进行得很好,直到需要注册我的类型为止。 我的Web应用程序在带有Prism和MVVM的Silverlight 4上运行。 该示例使用“ Micr
请有人建议我如何使用运行时传递的参数注册一个类 public interface ITabContentSending { TabType TheTabType { get; set; }
我的解决方案中有三个项目。 一个拿着界面: public interface ISetupData { Dictionary Data { get; set; } } 接口(interface
我有两个服务 IServiceA 和 IServiceB。 IServiceB 的具体实现如下所示: public class ServiceB : IServiceB { public Se
我正在尝试执行以下操作但失败了: class base {} class derived1 : base {} class derived2 : base {} interface itr where
这是一个示例控制台应用程序(添加 Unity NugGet 包后它将运行良好)似乎显示了 Unity 中的错误: using System; using Microsoft.Practices.Uni
我按照本教程开始使用 Autofac: http://flexamusements.blogspot.com/2010/09/dependency-injection-part-3-making-ou
我想使用 Autofac 探索自定义拦截器。我目前正在为 DynamicProxy 使用 Autofac 4.2.0 版和 CaSTLe.Core 3.3.3 版。 我从以下基本行为开始,想在 Aut
我一直在使用 Microsoft 的 Unity IOC 容器。 RegisterType() 方法有一堆重载看起来都类似于 IUnityContainer RegisterType(Type t,
我有一个使用 Unity 的应用程序。在应用程序的一个区域中,代码扫描程序集以使用以下代码注册类型(自动注册): public class CommonRegistry : UnityRegistry
我正在使用 UnityContainer,我想注册一个接口(interface),而不是一个类型,而是另一个接口(interface)。不幸的是,我无法干净地做到这一点.. 我有几个通用的接口(int
我一直在使用 Unity 容器并注意到一个奇怪的行为。我有一个类,它实现了多个接口(interface)。我希望此类在具有不同生命周期的应用程序的不同位置使用。所以我已经将 IFooDerived1
使用 AutoFac 时,您可以使用 .RegisterType 将类与接口(interface)相关联,但您也可以使用 .Register(它允许您通过一个 lambda)。 对于具有无参数构造函数
我正在使用 Unity 实例化一些对象,我发现无论我尝试什么,Unity 都会为我的对象创建单例。 根据文档: http://msdn.microsoft.com/en-us/library/dd20
我需要注册许多类型映射,但对于少数类型映射,我需要使用不同的依赖注入(inject)属性重新注册。 对于 Unity,这似乎是不可能的,并且这似乎是 RegisterType() 的一个错误。 这是一
我正在尝试自动注册存储库: 这行得通,但我不喜欢它,因为在服务层类中,我必须提供具体的 EntityRepository给构造函数而不是提供接口(interface) IRepository publ
我是 Autofac 的新手,我想了解 Web api 2(.Net 框架)中 RegisterInstance 和 RegisterType 之间的区别。在他的文档中有一个简单的 example v
这是我的服务构造函数的样子: public Service(string path) 我正在像这样配置统一: IUnityContainer container = new UnityContaine
我有一个统一的运行代码。 现在我想使用 Moq 对 ASP-MVC 进行单元测试。 在 global.asax 的代码中,我有以下内容: IUnityContainer container = new
我是一名优秀的程序员,十分优秀!