我如何标记MyClass无法复审,但有测试诉讼。
public class MyClass
{
}
public class MyAttribute : System.Attribute
{
bool Reviewed { get; set; }
bool HasTestSuit { get; set; }
}
答案 0 :(得分:2)
试试这个。
在MyAttribute类中声明构造函数。
public class MyAttribute : System.Attribute
{
bool Reviewed { get; set; }
bool HasTestSuit { get; set; }
public MyAttribute(bool hasReviewed,bool hasTestSuite)
{
this.Reviewed = hasReviewed;
this.HasTestSuit = hasTestSuite;
}
}
现在设置属性如下所示。
[MyAttribute(false, true)]
public class MyClass
{
}
您可以通过以下链接了解有关自定义属性的更多信息。
https://msdn.microsoft.com/en-us/library/84c42s56(v=vs.110).aspx
答案 1 :(得分:1)
[MyAttribute(false, true)]
public class MyClass
{
}
public class MyAttribute : System.Attribute
{
public MyAttribute(bool reviewed, bool hasTestSuit)
{
this.Reviewed = reviewed;
this.HasTestSuit = hasTestSuit;
}
bool Reviewed { get; set; }
bool HasTestSuit { get; set; }
}