Esempio n. 1
0
        public IDifference[] CompareProcessTemplates(ProcessTemplate current, ProcessTemplate goal)
        {
            var differences = new List<IDifference>();

            var mm = new MatchAndMap<WorkItemTypeDefinition, string>(i => i.Name, StringComparer.OrdinalIgnoreCase, _processTemplateMap.WorkItemTypeMap);
            var matchResult = mm.Match(current.WorkItemTypeDefinitions, goal.WorkItemTypeDefinitions);

            foreach (var goalItem in matchResult.GoalOnly)
            {
               differences.Add(new AddedWorkItemTypeDefinitionDifference(goalItem));
            }

            foreach (var currentItem in matchResult.CurrentOnly)
            {
               differences.Add(new RemovedWorkItemTypeDefinitionDifference(currentItem.Name));
            }

            var witdComparer = new WorkItemTypeDefinitionComparer(_processTemplateMap);
            foreach (var pair in matchResult.Pairs)
            {
                differences.AddRange(witdComparer.FindDifferences(pair.Current, pair.Goal));
            }

            return differences.ToArray();
        }
        public ProcessTemplate FromActiveTeamProject(Uri collectionUri, string projectName)
        {
            var collection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(collectionUri);

            var processTemplate = new ProcessTemplate
                                  {
                                      WorkItemTypeDefinitions = GetTeamProjectWorkItemTypeDefinitions(collection, projectName)
                                  };

            return processTemplate;
        }
        public ProcessTemplate FromCollectionTemplates(Uri collectionUri, string processTemplateName)
        {
            var collection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(collectionUri);

            var processTemplate = new ProcessTemplate();
            using (var downloader = new ProcessTemplateDownloader(collection, processTemplateName))
            {
                var processTemplateReader = new ProcessTemplateReader(downloader.TemplatePath);
                processTemplate.WorkItemTypeDefinitions = processTemplateReader.WorkItemTypeDefinitions.ToList();
            }

            return processTemplate;
        }