generic-interface

    1热度

    1回答

    我有一个接口IBakeable<T>每个有一个事件OnCooked 几个数据类的Pie和Bread 我有它实现IBakeable<Pie>和IBakeable<Bread> 为了一个类为了实现这一点,我认为我必须明确地实现接口 public class BaseHeatSource: IBakeable<Pie>, IBakeable<Bread> { private event Ev

    0热度

    1回答

    我有这个登记: builder.RegisterAssemblyTypes(assembly) .AsClosedTypesOf(typeof(IBusinessRule<>)) .AsImplementedInterfaces() .SingleInstance(); 我解决这个问题是这样的: using (var scope = Container

    1热度

    1回答

    我正在按照工作单元模式进行教程,我的代码无法编译,因为它无法识别接口签名中的哪个部分,并且它不识别类型T. using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Text; using System.Threading.T

    0热度

    2回答

    任何人都可以提出一种方法来通用以下接口,所以我可以有一个单一的接口,而不是每个存储库一个接口。 public interface IClass1Repository { Class1 NewEntity(); Class1 AddOrUpdate(Class1 entity); Class1 GetById(int Id); Class1 GetByNav

    0热度

    1回答

    由于泛型接口,我想要解析开放式泛型服务。我使用autofac。 每个具体的服务只适用于具体的类。 我只能用一个generic param解决一个服务[见SingleOpenGenericResolveTest]。是否可以注册&解决许多服务与许多T-params [见MultiOpenGenericResolveTest]? 我只为IService添加了一个具体类,但它可能是许多类T。 (TRegi

    2热度

    2回答

    假设下面的界面,我使用来定义参数类型和用于存储过程返回类型... public interface IStoredProcedure<out TReturn, out TParameter> where TReturn : class where TParameter : class { TReturn ReturnType { get; } TPara

    4热度

    2回答

    我有一个通用的接口彼此相连。 public interface IA { int val { get; set; } } public interface IB<T> where T:IA { T a_val { get; set; } } public interface IC<T> where T : IB<IA> { T b_val { get;

    0热度

    1回答

    我正在使用Web API 2应用程序并使用Unity依赖注入。 我有多种类型的过滤器:名称,品牌,类型... 我想创建一个名为接口:IFilterService并迫使所有其他类来实现它,然后我调用该接口的IEnumerable和注入正确的类型。 界面: public interface IFilterService<T> { bool CanHandle(FilterType type

    0热度

    1回答

    我是一个快捷的初学者。学习时有些事情让我感到困惑。现在我想定义一个抽象类或者定义一些纯粹的虚拟方法,但是我找不到一个办法。我有一个关联类型的协议(这也困惑了我,为什么不使用泛型协议),有些方法需要在基类中实现,其他类需要从基类继承,他们应该在协议中实现其他方法,我能怎么做? 例如: Ptotocol P{ typealias TypeParam func A() fu

    2热度

    2回答

    如何检查某个类以任何方式实现通用接口? 我有以下几点: public class SomeQueryObject : IQueryObject<SomeQueryDto> { public SomeQueryDto query { get; set; } = new SomeQueryDto(); } public class SomeQueryDto : BaseQueryDt