0
我希望我的类中的属性在设计时返回与运行时不同的值。我可以使用LicenseManager.UsageMode
检测到我处于设计模式,但将其从我的发布版本中排除是很好的。在设计和运行时从属性获取不同的值
有没有更好的方法来实现下面的代码,或许使用Conditional
属性?
public int MyValue
{
get
{
int my_value = 10;
#if DEBUG
if (LicenseManager.UsageMode == LicenseUsageMode.Designtime)
{
my_value = 20;
}
#endif
return my_value;
}
}
为什么不使用设计时属性?它应该在属性获得者中具有正确的价值。 – 2011-01-12 16:36:28