예제 #1
0
        static void GetDeepDependency(IEnumerable <TfsItem> inputList, IEnumerable <TfsItem> compareList, DependencyList <TfsItem> dependencyList)
        {
            List <TfsItem> nextIterationInput = new List <TfsItem>();

            foreach (var input in inputList)
            {
                foreach (var compare in compareList)
                {
                    IEnumerable <ImpactFileInfo> intersectFiles = compare.FilesInfo.Intersect(input.FilesInfo, new GenericEqualityComparer <ImpactFileInfo, string>(x => x.FileName));
                    if (intersectFiles.Count() > 0)
                    {
                        input.DependentTfsList.Add(new DependentTfs()
                        {
                            TfsID = compare.TfsID, IntersectFiles = intersectFiles.ToList()
                        });
                        nextIterationInput.Add(compare);
                    }
                }
                dependencyList.Add(input);
            }
            if (nextIterationInput.Count > 0)
            {
                GenericEqualityComparer <TfsItem, int> genericComparer = new GenericEqualityComparer <TfsItem, int>(x => x.TfsID);
                nextIterationInput = nextIterationInput.Distinct(genericComparer).ToList();
                GetDeepDependency(nextIterationInput, compareList.Except(nextIterationInput, genericComparer), dependencyList);
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            List <ImpactFile> HotFixImpactFiles        = GetImpactFilesList(@"../../Data/Day0Day1.txt");
            List <ImpactFile> RecentChangesImpactFiles =
                GetImpactFilesList(@"../../Data/After60ImpactFiles.txt");
            GenericEqualityComparer <ImpactFileInfo, string> comparer = new GenericEqualityComparer <ImpactFileInfo, string>(x => x.FileName);
            var imapctFilesByIdHF = HotFixImpactFiles.GroupBy(f => f.TfsID).Select(g =>
                                                                                   new TfsItem
            {
                TfsID     = g.Key,
                FilesInfo = g.Select(info => new ImpactFileInfo
                {
                    FileName    = info.FileName,
                    CheckedInBy = info.CheckedInBy,
                    CheckInDate = info.CheckInDate
                }).OrderByDescending(date => date.CheckInDate)
                            .Distinct(comparer).ToList()
            });
            var recentTFSItems = RecentChangesImpactFiles.GroupBy(f => f.TfsID).Select(g =>
                                                                                       new TfsItem
            {
                TfsID     = g.Key,
                FilesInfo = g.Select(info => new ImpactFileInfo
                {
                    FileName    = info.FileName,
                    CheckedInBy = info.CheckedInBy,
                    CheckInDate = info.CheckInDate
                }).OrderByDescending(date => date.CheckInDate)
                            .Distinct(comparer).ToList()
            });
            DependencyList <TfsItem> dependencyList = new DependencyList <TfsItem>();

            GetDeepDependency(imapctFilesByIdHF, recentTFSItems, dependencyList);
            DependencyList <TfsItem>         sortedTfsList = Sort(dependencyList, x => x.DependentTfsList, (x) => { return(dependencyList.Where(y => y.TfsID == x.TfsID).FirstOrDefault()); }, x => x.TfsID);
            List <DependencyList <TfsItem> > groupDepList  = Group(dependencyList, x => x.DependentTfsList, (x) => { return(dependencyList.Where(y => y.TfsID == x.TfsID).FirstOrDefault()); }, new GenericEqualityComparer <TfsItem, int>(x => x.TfsID));
            string xml = GetXMLFromObject <DependencyList <TfsItem> >(dependencyList);

            Console.Read();
        }
예제 #3
0
        public static List <DependencyList <T> > Group <T, D, TKey>(DependencyList <T> depList, Func <T, IEnumerable <D> > getDependencies, Func <D, T> getDependencyDetail, GenericEqualityComparer <T, TKey> comparer = null)
        {
            Dictionary <T, int>        visited = new Dictionary <T, int>(comparer);
            List <DependencyList <T> > sorted  = new List <DependencyList <T> >();

            foreach (var v in depList)
            {
                Visit(v, getDependencies, getDependencyDetail, visited, sorted);
            }
            return(sorted);
        }
예제 #4
0
        public static DependencyList <T> Sort <T, D, TKey>(DependencyList <T> source, Func <T, IEnumerable <D> > getDependencies, Func <D, T> getDependecyDetail, GenericEqualityComparer <T, TKey> comparer)
        {
            var sorted  = new DependencyList <T>();
            var visited = new Dictionary <T, bool>(comparer);

            foreach (var item in source)
            {
                Visit(item, getDependencies, getDependecyDetail, sorted, visited);
            }

            return(sorted);
        }