Tuesday, 10 September 2013

TFS api get query parameters from context

TFS api get query parameters from context

Is it possible to get the default parameters like @Project, @Me, ... from
the current TFS context with the TFS API?
var contextManager = GetService<ITeamFoundationContextManager>(); // from
Team Explorer (VS Extension)
var tpc = contextManager.CurrentContext.TeamProjectCollection;
var workItemStore = (WorkItemStore)tpc.GetService(typeof(WorkItemStore));
var project = workItemStore.Projects[teamProjectName];
var parameters = new Dictionary<string, string> { { "project",
project.Name } }; // get them from context!?
var qry = project.QueryHierarchy.First(q => ...) as QueryDefinition;
var items = store.Query(qry, parameters);

No comments:

Post a Comment