jjzjj

IInterface

全部标签

c# - 网络核心 : register implementation with multiple interfaces and lifestyle Singleton

考虑以下接口(interface)和类定义:publicinterfaceIInterface1{}publicinterfaceIInterface2{}publicclassMyClass:IInterface1,IInterface2{}有没有办法像这样用多个接口(interface)注册一个MyClass的实例:...services.AddSingleton();...并用像这样的不同接口(interface)解析MyClass的单个实例:IInterface1interface1=app.ApplicationServices.GetService();IInterface

c# - 网络核心 : register implementation with multiple interfaces and lifestyle Singleton

考虑以下接口(interface)和类定义:publicinterfaceIInterface1{}publicinterfaceIInterface2{}publicclassMyClass:IInterface1,IInterface2{}有没有办法像这样用多个接口(interface)注册一个MyClass的实例:...services.AddSingleton();...并用像这样的不同接口(interface)解析MyClass的单个实例:IInterface1interface1=app.ApplicationServices.GetService();IInterface

c# - 无法实现接口(interface)成员,因为它没有 List<IInterface> 的匹配返回类型

我有接口(interface)IChild和IParent.IParent有一个成员是List.我希望有实现IParent的类每个类都有一个实现IChild的成员:publicinterfaceIChild{}publicinterfaceIParent{Lista{get;set;}}publicclassChildA:IChild{}publicclassChildB:IChild{}publicclassParentA:IParent{publicLista{get;set;}}publicclassParentB:IParent{publicLista{get;set;}}但是
12