I'm writing a console app to do code generation during our Continuous Integration process. To do a Get from TFS Version Control, I'm hitting its managed API, specifically the Workspace object. The Workspace.Get() method has a number of overloads. The one I'm concerned with takes a local or server path and VersionSpec wrapped in a GetRequest object and a GetOptions parameter. I want to force a get in all cases as well as ensure that I will overwrite any existing files on the local file system. Normally I would expect there to be a GetOptions entry for GetAll and Overwrite combined. There isn't, but each of these values does exist on its own within the enumeration. What I did notice is that the values in the enumeration look a lot like bitmask values. GetOptions Enumeration
| Name | Value |
| None | 0 |
| Overwrite | 1 |
| GetAll | 2 |
| Preview | 4 |
Dim request as GetRequest
request=New GetRequest({local or server path}, VersionSpec.Latest)
wkspace.Get(request, _
CType(GetOptions.GetAll + GetOptions.Overwrite, GetOptions))
Since the GetOptions enum is a bitmask you can use the approach above or use a Bitwise-OR to combine these values.
wkspace.Get(request, CType(GetOptions.GetAll OR GetOptions.Overwrite, GetOptions))))

2 comments:
You can also do a GetOptions.GetAll | GetOptions.Overwrite
Thanks Steve - this was helpful.
Post a Comment