0

I have written code to get latest from TFS using the client APIs. I would like to be updated on the progress and I understand that the properties "Total" and "Current" of GettingEventArgs can be used. But these properties are not visible during design time but only visible at runtime (see image below). But event at runtime, I am unable to fetch them using reflection as give below.

    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);
     }

This does not find the property and I get a Null reference on the "GetProperty". I hope the syntax is correct.

Properties in quickwatch

Any thoughts on how to get hold of these property values?

Lalman
  • 946
  • 2
  • 11
  • 27
  • I figured out that the access modifiers mean that the properties are "internal". I am wondering why there are no "public" or "accessible" equivalents for these. Still have not found a way to show "percent progress"... – Lalman Mar 12 '12 at 12:05
  • It turned out to be quite simple, something I had never used before. The Binding Flags allow access to internal/private or any kind of property. See answer to [this quesion](http://stackoverflow.com/questions/9667654/c-sharp-internal-properties-readable-in-quickwatch-but-not-using-reflection) – Lalman Mar 22 '12 at 05:11

1 Answers1

1

There is an error in GettingEventArgs status = (GettingEventArgs)e;. You probably ment

OperationStatus status = e.Status;
Nikola Markovinović
  • 18,963
  • 5
  • 46
  • 51
  • Nikola, the OperationStatus only shows the current status such as "Getting", but does not provide a way to get the "percent progress". GettingEventArgs, whereas has properties "Total" and "Current" but they are "internal". I do not seem to find anything that can provide the total/current or the percent progress. I raised this because of this (http://social.msdn.microsoft.com/Forums/eu/tfsversioncontrol/thread/ddd3db8e-54ca-4841-8195-e64e3242b991?prof=required) MSDN Blog query that says "it is possible" – Lalman Mar 12 '12 at 11:58
  • As Current and Total are not public, you need to [call this overload of GetProperty()](http://msdn.microsoft.com/en-us/library/zy0d4103.aspx) on e. – Nikola Markovinović Mar 12 '12 at 12:23