protected override void ProcessRecordInEH() { TfsTeamProjectCollection collection = EnsureCollection(); WorkItemStore workItemStore = EnsureWorkItemStore(); List <Project> projects = workItemStore.MatchProjects(Name).ToList(); if (projects.Count == 0) { throw new InvalidOperationException(string.Format("Cannot find project named {0}.", Name)); } else if (projects.Count > 1) { throw new InvalidOperationException(string.Format("More than 1 projects found with name {0}.", Name)); } CmdletContext.Collection = collection; CmdletContext.WorkItemStore = workItemStore; CmdletContext.Project = projects[0]; if (PassThru.IsPresent) { WriteObject(CmdletContext.Project); } }
public static IEnumerable <Project> MatchProjects(this TfsTeamProjectCollection collection, string namePattern) { var workItemStore = new WorkItemStore(collection); if (workItemStore == null) { throw new InvalidOperationException("Access denied when getting work item store."); } return(workItemStore.MatchProjects(namePattern)); }
protected override void ProcessRecordInEH() { if (string.IsNullOrWhiteSpace(Name)) { Name = "*"; } WorkItemStore workItemStore = EnsureWorkItemStore(); foreach (var project in workItemStore.MatchProjects(Name)) { WriteObject(project); } }