Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
        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));
        }
Beispiel #3
0
        protected override void ProcessRecordInEH()
        {
            if (string.IsNullOrWhiteSpace(Name))
            {
                Name = "*";
            }

            WorkItemStore workItemStore = EnsureWorkItemStore();

            foreach (var project in workItemStore.MatchProjects(Name))
            {
                WriteObject(project);
            }
        }