我还在努力学习。。。很多。我的理解是,接口和抽象类都不能“要求”类具有构造函数。那么,由于T4非常糟糕,有人能告诉我创建T4模板的正确方向吗?该模板创建以下代码:
Make a T4 template that
1. reads all the classes in a file or namespace
2. produces code that has:
2.1 interface name of "I"+ClassName, e.g. "IClassName"
2.2 model name of ClassName+"Model", e.g. "ClassNameModel"
2.3 model code of:
public ClassNameModel<T>
where T: IClassName, new()
{
private readonly T t;
public ClassNameModel()
{
t = new T();
}
public ClassNameModel(T t)
{
this.t = t;
}
}
谢谢你的帮助。蒂亚