01-14-2016 05:49 AM
Hi,
I want to access data from TFS (Microsoft's Team Foundation Server) using LabVIEW.
To get connection to TFS here is the C# code .
TfsTeamProjectCollection projectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("TFSServerString"));
ITestManagementService teamProject = projectCollection.GetService<ITestManagementService>();
ITestManagementTeamProject testProject = teamProject.GetTeamProjec("ABC");
I was able to get projectCollection object in LabVIEW, but facing issue in calling "GetService" method. I am not able to get reference for "ITestManagementService". Please see attached vi.
Can you please suggest what can be done for this?
Thanks in advance.
01-14-2016 06:58 AM
Have you tried the "To More Specific Class" to cast the gneric Collection class into the more specific interface? Otherwise you may try to use the "Variant to Data" node in the ActiveX menu. Seems it can also do something similar like this for .Net refnums.
01-14-2016 08:58 AM
As I mentioned, I am not able to select "ITestManagementService" for .net reference . So type casting to / from that type is not working.
01-14-2016 12:15 PM
But do you know where is this class in the library?
You can create dNet class constant (I do not know where is it in pallettes, so I use Create constant from .Net property node terminal. Then you can right click it -> "Select .Net Class" -> Browse and find way to ITestManagementService
01-14-2016 06:41 PM
Yes, I tried to do that way also. After selecting "ITestManagementService" from object browser I press ok. (ObjectSelection.png) Then when I check the current .net object this constant refering to is not matching with selected object. (.netType.png)
This is the same behaviour I am seeing if I do with Constant or Control.
01-15-2016 04:01 AM
Do you get other classes when unchecking the "Show Creatable objects only" checkbox? This has IMHO to do if you can use a constructor to create an object, but this class is never constructed in itself but always retrieved through the server factory.
01-15-2016 09:00 AM
Can you try to convert ITestManagementService into system.type using "To more Generic class" and then convert GetService output into ITestManagementService class with "To more specific class"?
GetService output type should match type specifying input, but I do not know how LabVIEW deals with outputs that adapt to input in case of .NET functions.
01-15-2016 10:09 AM
ITestManagementService is an Interface, so we don't have constructor for that.
If I uncheck the "Show creatable objects only", I didn't see any additional class coming in the list.
Can we reference Interface in LabVIEW and then get "TypeOf" it?
01-16-2016 07:25 PM
>> Can we reference Interface in LabVIEW and then get "TypeOf" it?
I would say that "Type of" object in LabVIEW is that blank reference of specific .Net types. There is no real object or interface associated with them - trying to call methods would yield "no object exists" error, but type is correct.. That is why I suggested using "to Generic" and "To specific" converters.
I tried to look into System.Type library for this method - "get Type" object from specific object, but no luck.
01-17-2016 06:19 AM - edited 01-17-2016 06:21 AM
Alexander is right, the LabVIEW refnum is the interface, while the value in the refnum is the object instance. The interface determines what methods and properties can be invoked on the object, but in order for this to be executable there needs to be an actual object instance.
Now why can't the refnum be assigned the Interface you desire? Looking at MSDN there seems to be something about TfsTeamProjectCollection.GetService() that looks a bit strange. There are in fact two methods with this name. One takes a parameter of type System.Type that determines the type of the returned service. The other uses Generics (the variant shown in your C# code with <ITestManagementService> after the method name). LabVIEW does not support Generic interfaces at all, so you can't call the second method from LabVIEW. But the one shown in your diagram is the first one so should work anyhow. You just need to be able to create a System.Type that describes the ITestManagementService interface.
System.Type however is not something used in normal code but rather something that is part of so called reflection, the technique to retrospectively inspect or build classes at runtime without prior knowledge of the exact datatype. It's rather involved and not easy to understand. However it can be used to create objects in LabVIEW that have Generic interfaces but it requires you to know the exact string to create that object using reflection. This shows a way how to use reflection to create a particular object type. You would then use that both as input to the GetService() method. After that I'm a little lost at what might be the problem with ITestManagementService here. It's not that it makes use of Generics itself, which would otherwise also cause it to not even be available in the browse dialog.
Unfortunately I don't have any machine available at this point with VS2010 or newer available so can't test it out myself at the moment.