예제 #1
0
        public static COMRegistry Diff(COMRegistry left, COMRegistry right, COMRegistryDiffMode mode, IProgress <Tuple <string, int> > progress)
        {
            const int total_count = 10;

            COMRegistry ret = new COMRegistry(COMRegistryMode.Diff);

            Report(progress, "CLSIDs", 1, total_count);
            ret.m_clsids = DiffDicts(left.m_clsids, right.m_clsids, mode, p => p.Clsid);
            Report(progress, "ProgIDs", 2, total_count);
            ret.m_progids = DiffDicts(left.m_progids, right.m_progids, mode, p => p.ProgID);
            Report(progress, "MIME Types", 3, total_count);
            ret.m_mimetypes = DiffLists(left.m_mimetypes, right.m_mimetypes, mode).ToList();
            Report(progress, "AppIDs", 4, total_count);
            ret.m_appid = DiffDicts(left.m_appid, right.m_appid, mode, p => p.AppId);
            Report(progress, "Interfaces", 5, total_count);
            ret.m_interfaces = DiffDicts(left.m_interfaces, right.m_interfaces, mode, p => p.Iid);
            Report(progress, "Categories", 6, total_count);
            ret.m_categories = DiffDicts(left.m_categories, right.m_categories, mode, p => p.CategoryID);
            Report(progress, "LowRights", 7, total_count);
            ret.m_lowrights = DiffLists(left.m_lowrights, right.m_lowrights, mode).ToList();
            Report(progress, "TypeLibs", 8, total_count);
            ret.m_typelibs = DiffDicts(left.m_typelibs, right.m_typelibs, mode, p => p.TypelibId);
            Report(progress, "PreApproved", 9, total_count);
            ret.m_preapproved = DiffLists(left.m_preapproved, right.m_preapproved, mode).ToList();
            Report(progress, "Runtime Classes", 10, total_count);
            ret.m_runtime_classes = DiffDicts(left.m_runtime_classes, right.m_runtime_classes, mode, p => p.Name);
            return(ret);
        }
예제 #2
0
 static SortedDictionary <S, T> DiffDicts <S, T>(IDictionary <S, T> left, IDictionary <S, T> right, COMRegistryDiffMode mode, Func <T, S> key_selector)
 {
     return(DiffLists(left.Values, right.Values, mode).ToSortedDictionary(key_selector));
 }
예제 #3
0
        static IEnumerable <T> DiffLists <T>(IEnumerable <T> left, IEnumerable <T> right, COMRegistryDiffMode mode)
        {
            switch (mode)
            {
            case COMRegistryDiffMode.LeftOnly:
                return(left.Except(right));

            case COMRegistryDiffMode.RightOnly:
                return(right.Except(left));

            default:
                throw new ArgumentException(nameof(mode));
            }
        }