简体   繁体   English

通用参数中的Visual Studio建模和协方差

[英]Visual Studio Modeling and covariance in generic arguments

I'm using Visual Studio Modeling project and code generation with partial clases. 我正在使用Visual Studio Modeling项目和部分分类的代码生成。 Some interfaces have generic parameters and generic constraints for these parameters. 一些接口具有通用参数和这些参数的通用约束。 I'm using Template Parameters to specify the parameters, their types and their constraints. 我正在使用模板参数来指定参数,其类型和约束。 All code is generated successfully so far. 到目前为止,所有代码均已成功生成。

Now, i want to add a variance and covariance in these generic parameters. 现在,我想在这些通用参数中添加方差和协方差。 Here is the problem: 这是问题所在:

How i can specify the "in" or "out" tag in generic parameters? 如何在通用参数中指定“输入”或“输出”标签?

Edit: In addition, i want put generic arguments in Methods too, but Template Parameters not found in method properties toolbox. 编辑:此外,我也想在方法中放入通用参数,但是在方法属性工具箱中找不到模板参数。 It's possible specify generic parameters to methods too? 也可以为方法指定通用参数吗?

This is pretty generic: 这是非常通用的:

public interface IFoo<in T, out TResponse>
{
    TResponse DoSomething(T entity);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM