Tag: 团结容器

Unity将两个接口注册为一个单例

我如何注册两个不同的接口在同一个实例的Unity …目前我正在使用 _container.RegisterType<EventService, EventService>(new ContainerControlledLifetimeManager()); _container.RegisterInstance<IEventService>(_container.Resolve<EventService>()); _container.RegisterInstance<IEventServiceInformation>(_container.Resolve<EventService>()); 哪个工作,但不好看.. 所以,我想你明白了。 EventService实现了两个接口,如果我parsing了接口,我想要引用同一个对象。 克里斯