Esempio n. 1
0
        static ConflictResults GetConflicts(MockConflictItem[] itemsToCommit, MockConflictItem[] itemsNotToCommit, ITaskItem[] packageOverrides)
        {
            ConflictResults ret = new ConflictResults();

            void ConflictHandler(MockConflictItem item)
            {
                ret.Conflicts.Add(item);
            }

            void UnresolvedConflictHandler(MockConflictItem item)
            {
                ret.UnresolvedConflicts.Add(item);
            }

            string[] packagesForRank = itemsToCommit.Concat(itemsNotToCommit)
                                       .Select(i => i.PackageId)
                                       .Where(id => !id.StartsWith("Unranked", StringComparison.OrdinalIgnoreCase))
                                       .Distinct()
                                       .OrderBy(id => id)
                                       .ToArray();

            var overrideResolver = new PackageOverrideResolver <MockConflictItem>(packageOverrides);

            var resolver = new ConflictResolver <MockConflictItem>(new PackageRank(packagesForRank), overrideResolver, new MockLog());

            resolver.ResolveConflicts(itemsToCommit, GetItemKey, ConflictHandler,
                                      unresolvedConflict: UnresolvedConflictHandler);

            resolver.ResolveConflicts(itemsNotToCommit, GetItemKey, ConflictHandler,
                                      commitWinner: false,
                                      unresolvedConflict: UnresolvedConflictHandler);

            return(ret);
        }