我有以下课程:
public class Fluently
{
public Fluently Is(string lhs)
{
return this;
}
public Fluently Does(string lhs)
{
return this;
}
public Fluently EqualTo(string rhs)
{
return this;
}
public Fluently LessThan(string rhs)
{
return this;
}
public Fluently GreaterThan(string rhs)
{
return this;
}
}
在英语语法中,你不能有“is something equal to something”或“does something greater than something”,所以我不希望 Is.EqualTo 和 Does.GreaterThan 成为可能。有什么办法可以限制吗?
var f = new Fluently();
f.Is("a").GreaterThan("b");
f.Is("a").EqualTo("b"); //grammatically incorrect in English
f.Does("a").GreaterThan("b");
f.Does("a").EqualTo("b"); //grammatically incorrect in English
谢谢!