我已经编写了使用客户端API从TFS获取最新内容的代码。我希望更新进度,并且我明白可以使用GettingEventArgs的“总计”和“当前”属性。但是这些属性在设计时不可见,但仅在运行时可见(请参见下图)。但是在运行时事件,我无法使用反射来获取它们,如下所示。TFS获取最新代码 - GettingEventArgs属性'Total'和'Current'不可见
static void versionControl_Getting(object sender, GettingEventArgs e)
{
GettingEventArgs status = (GettingEventArgs)e;
int curr = (int)status.GetType().GetProperty("Current").GetValue(status, null);
int tot = (int)status.GetType().GetProperty("Total").GetValue(status, null);
}
这没有找到属性,我得到一个“GetProperty”的空引用。我希望语法是正确的。
如何获得这些属性值的保持有什么想法?
我发现访问修饰符意味着属性是“内部的”。我想知道为什么没有这些“公共”或“可访问”等价物。仍然没有找到一种方法来显示“百分比进度”... – Lalman 2012-03-12 12:05:04
结果很简单,我以前从未使用过。绑定标志允许访问内部/私人或任何类型的财产。查看答案[这个问题](http://stackoverflow.com/questions/9667654/c-sharp-internal-properties-readable-in-quickwatch-but-not-using-reflection) – Lalman 2012-03-22 05:11:13