Exemplo n.º 1
0
        public override void Save()
        {
            //  Keep track of whether the original and final sets of categories
            //  differ and run particular rules if they differ.
            if (IsChanged())
            {
                foreach (IResource res in _resultCats)
                {
                    if (_originalCats.IndexOf(res) == -1)
                    {
                        Core.CategoryManager.AddResourceCategory(_contact, res);
                    }
                    _originalCats = _originalCats.Minus(res.ToResourceList());
                }

                //  ... and remove those which are not now set.
                foreach (IResource res in _originalCats)
                {
                    Core.CategoryManager.RemoveResourceCategory(_contact, res);
                }


                Core.FilterEngine.ExecRules(StandardEvents.CategoryAssigned, _contact);
            }
        }
Exemplo n.º 2
0
        private void ScheduleForUpdate(IResource root)
        {
            RSSPlugin plug = RSSPlugin.GetInstance();

            if (plug == null)
            {
                return;
            }
            foreach (IResource res in root.GetLinksTo(null, Core.Props.Parent).ValidResources)
            {
                if (res.Type == "RSSFeedGroup")
                {
                    ScheduleForUpdate(res);
                }
                else if (res.Type == "RSSFeed" && _oldRSSFeedList.IndexOf(res) == -1)
                {
                    if (!res.HasProp(Props.UpdateFrequency) || !res.HasProp(Props.UpdatePeriod))
                    {
                        res.SetProp(Props.UpdateFrequency, 4);
                        res.SetProp(Props.UpdatePeriod, UpdatePeriods.Hourly);
                    }
                    plug.ScheduleFeedUpdate(res);
                }
            }
        }
Exemplo n.º 3
0
 private void PerformImport(IResource importRoot, bool addToWorkspace)
 {
     _imported = true;
     if (addToWorkspace)
     {
         _oldRSSFeedList = Core.ResourceStore.GetAllResources("RSSFeed");
         // Instantinate
         _oldRSSFeedList.IndexOf(importRoot);
     }
     foreach (HashSet.Entry importerName in  _selectedFeedImporters)
     {
         IFeedImporter importer = _feedImporters[importerName.Key as string] as IFeedImporter;
         try
         {
             importer.DoImport(importRoot, addToWorkspace);
         }
         catch (Exception ex)
         {
             Core.UIManager.QueueUIJob(new ErrorReportJob(ReportImportError), importerName.Key as string, ex.Message);
         }
     }
     // Schedule all feeds to update
     if (addToWorkspace)
     {
         ScheduleForUpdate(importRoot);
         _oldRSSFeedList = null;
     }
 }
Exemplo n.º 4
0
        public bool AcceptNode(JetListViewNode node)
        {
            IResource res = (IResource)node.Data;

            if (res.Type == FilterManagerProps.ConditionResName ||
                res.Type == FilterManagerProps.ConditionTemplateResName)
            {
                return(UnusedConditions.IndexOf(res.Id) >= 0);
            }
            else
            if (res.Type == FilterManagerProps.ConditionGroupResName)
            {
                IResourceList condInGroup = res.GetLinksOfType(FilterManagerProps.ConditionResName, Core.Props.Parent).Union
                                                (res.GetLinksOfType(FilterManagerProps.ConditionTemplateResName, Core.Props.Parent));
                foreach (IResource cond in condInGroup)
                {
                    string appResType = cond.GetStringProp(Core.Props.ContentType);
                    if (ResourceTypeHelper.IsResourceTypeActive(appResType) &&
                        ResTypesIntersect(appResType, UsedResTypes))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemplo n.º 5
0
/*
 *      //  Config: 1 mail, 1 attachment, 2 contacts, 2 accounts.
 *      //  Action: Unlink account from the first contact;
 *      //  Expected: new contact is created, mail is relinked to it, and its
 *      //            attachment is also relinked to it.
 *      [Test] public void UnlinkContactAndAccountTestMailWithAttachments()
 *      {
 *          IContact main  = _contactManager.FindOrCreateContact( "account1", "Michael Gerasimov" );
 *          IContact extra = _contactManager.FindOrCreateContact( "account2", "FirstName LastName" );
 *          IResource account1 = Core.ResourceStore.FindUniqueResource( "EmailAccount", _contactManager.Props.EmailAddress, "account1" );
 *          IResource account2 = Core.ResourceStore.FindUniqueResource( "EmailAccount", _contactManager.Props.EmailAddress, "account2" );
 *          IResourceList contacts = _storage.GetAllResources( "Contact" );
 *          Assert.AreEqual( 2, contacts.Count );
 *
 *          IResource email = _storage.NewResource( "email" );
 *          email.SetProp( "Subject", "Subject1" );
 *          Core.ContactManager.LinkContactToResource( _contactManager.Props.LinkFrom, main.Resource, email, account1, "A" );
 *          Core.ContactManager.LinkContactToResource( _contactManager.Props.LinkTo, extra.Resource, email, account2, "B" );
 *
 *          IResource attach = _storage.NewResource( "email" );
 *          attach.SetProp( "Name", "AttachmentResource" );
 *          attach.SetProp( _contactManager.Props.LinkFrom, main.Resource );
 *          attach.SetProp( _contactManager.Props.LinkTo, extra.Resource );
 *          attach.SetProp( "Attachment", email );
 *
 *          //-----------------------------------------------------------------
 *          _contactManager.HardRemoveAccountFromContact( main.Resource, account1 );
 *          //-----------------------------------------------------------------
 *
 *          contacts = _storage.GetAllResources( "Contact" );
 *          Assert.AreEqual( 3, contacts.Count );
 *
 *          IResource newContact = email.GetLinkProp( _contactManager.Props.LinkFrom );
 *          Assert.IsTrue( newContact.Id != main.Resource.Id );
 *          Assert.IsTrue( attach.GetLinkProp( _contactManager.Props.LinkFrom ).Id == newContact.Id );
 *      }
 */
        //  Config: 1 mail, 1 attachment, 4 contacts, 4 accounts.
        //  Action: Unlink account from the first contact;
        //  Expected: new contact is created, mail is relinked to it, and its
        //            attachment is also relinked to it.
        [Test] public void UnlinkContactAndAccountTestMailWithAttachmentsLinkedToSeveralContacts()
        {
            IContact      to1      = _contactManager.FindOrCreateContact("account1", "Michael Gerasimov");
            IContact      to2      = _contactManager.FindOrCreateContact("account2", "F1 L1");
            IContact      to3      = _contactManager.FindOrCreateContact("account3", "F2 L2");
            IContact      extra    = _contactManager.FindOrCreateContact("account4", "F3 L3");
            IResource     account1 = Core.ResourceStore.FindUniqueResource("EmailAccount", _contactManager.Props.EmailAddress, "account1");
            IResource     account2 = Core.ResourceStore.FindUniqueResource("EmailAccount", _contactManager.Props.EmailAddress, "account2");
            IResource     account3 = Core.ResourceStore.FindUniqueResource("EmailAccount", _contactManager.Props.EmailAddress, "account3");
            IResource     account4 = Core.ResourceStore.FindUniqueResource("EmailAccount", _contactManager.Props.EmailAddress, "account4");
            IResourceList contacts = _storage.GetAllResources("Contact");

            Assert.AreEqual(4, contacts.Count);

            IResource email = _storage.NewResource("email");

            email.SetProp("Subject", "Subject1");
            Core.ContactManager.LinkContactToResource(_contactManager.Props.LinkTo, to1.Resource, email, account1, "B1");
            Core.ContactManager.LinkContactToResource(_contactManager.Props.LinkTo, to2.Resource, email, account2, "B2");
            Core.ContactManager.LinkContactToResource(_contactManager.Props.LinkTo, to3.Resource, email, account3, "B3");
            Core.ContactManager.LinkContactToResource(_contactManager.Props.LinkFrom, extra.Resource, email, account4, "A");

            IResource attach = _storage.NewResource("email");

            attach.SetProp("Name", "AttachmentResource");
            attach.SetProp(_contactManager.Props.LinkTo, to1.Resource);
            attach.SetProp(_contactManager.Props.LinkTo, to2.Resource);
            attach.SetProp(_contactManager.Props.LinkTo, to3.Resource);
            attach.SetProp(_contactManager.Props.LinkFrom, extra.Resource);
            attach.SetProp("Attachment", email);

            //-----------------------------------------------------------------
            _contactManager.HardRemoveAccountFromContact(to1.Resource, account1);
            //-----------------------------------------------------------------

            contacts = _storage.GetAllResources("Contact");
            Assert.AreEqual(5, contacts.Count);

            contacts = email.GetLinksOfType("Contact", _contactManager.Props.LinkTo);
            Assert.IsTrue(contacts.IndexOf(to1.Resource.Id) == -1);
            contacts = attach.GetLinksOfType("Contact", _contactManager.Props.LinkTo);
            Assert.IsTrue(contacts.IndexOf(to1.Resource.Id) == -1);
        }
Exemplo n.º 6
0
        public bool MatchResource(IResource res, IActionParameterStore actionStore)
        {
            IResourceList threadHeads = actionStore.ParametersAsResList();
            IResource     msg         = res;

            while (msg != null && threadHeads.IndexOf(msg) == -1)
            {
                msg = msg.GetLinkProp(Core.Props.Reply);
            }
            return(msg != null);
        }
Exemplo n.º 7
0
 public bool CanDropResources(IResource targetResource, IResourceList dragResources)
 {
     if (dragResources.Count > 0)
     {
         if (targetResource != _bookmarkService.BookmarksRoot)
         {
             if (targetResource.Type != "Folder")
             {
                 return(false);
             }
             IBookmarkProfile targetProfile = _bookmarkService.GetOwnerProfile(targetResource);
             foreach (IResource dragRes in dragResources)
             {
                 string           error;
                 IBookmarkProfile sourceProfile = _bookmarkService.GetOwnerProfile(dragRes);
                 if (sourceProfile == targetProfile)
                 {
                     if (targetProfile != null && !targetProfile.CanMove(dragRes, targetResource, out error))
                     {
                         return(false);
                     }
                 }
                 else
                 {
                     if (sourceProfile != null && !sourceProfile.CanDelete(dragRes, out error))
                     {
                         return(false);
                     }
                     if (targetProfile != null && !targetProfile.CanCreate(dragRes, out error))
                     {
                         return(false);
                     }
                 }
             }
             IResource temp = targetResource;
             do
             {
                 if (dragResources.IndexOf(temp) >= 0)
                 {
                     return(false);
                 }
                 temp = BookmarkService.GetParent(temp);
             } while(temp != null);
         }
         string[] types = dragResources.GetAllTypes();
         if (types.Length < 3)
         {
             return((types[0] == "Weblink" || types[0] == "Folder") &&
                    (types.Length == 1 || types[1] == "Weblink" || types[1] == "Folder"));
         }
     }
     return(false);
 }
Exemplo n.º 8
0
        private void _okButton_Click(object sender, System.EventArgs e)
        {
            HashSet updatesResources = new HashSet();

            for (int i = 0; i < content.Count; ++i)
            {
                IResource webLink = content[i];
                if (webLink.Type != "Weblink" && webLink.Type != "Folder")
                {
                    webLink = webLink.GetLinkProp("Source");
                }
                updatesResources.Add(webLink);
            }

            for (int i = 0; i < content.Count; ++i)
            {
                IResource webLink = content[i];
                if (webLink.Type != "Weblink" && webLink.Type != "Folder")
                {
                    webLink = webLink.GetLinkProp("Source");
                }
                IResource parent = BookmarkService.GetParent(webLink);
                while (parent != null)
                {
                    if (content.IndexOf(parent) >= 0)
                    {
                        updatesResources.Remove(webLink);
                        break;
                    }
                    parent = BookmarkService.GetParent(parent);
                }
            }

            int updateFreq = (_updateCheckBox.Checked) ? ((int)_hoursBox.Value * 60 * 60) : 0;
            int unitIndex  = _unitBox.SelectedIndex;

            if (unitIndex > 0)
            {
                updateFreq *= 24;
                if (unitIndex > 1)
                {
                    updateFreq *= 7;
                }
            }

            foreach (HashSet.Entry E in updatesResources)
            {
                new ResourceProxy((IResource)E.Key).SetPropAsync(FavoritesPlugin._propUpdateFreq, updateFreq);
            }

            Close();
        }
Exemplo n.º 9
0
        private static bool IsWorkspaceFit(IResource res)
        {
            bool result = true;

            IResourceList inWsps = res.GetLinksOfType(null, "InWorkspace");

            if (inWsps.Count > 0)
            {
                IResource currWsp = Core.WorkspaceManager.ActiveWorkspace;
                result = (currWsp == null) || (inWsps.IndexOf(currWsp) != -1);
            }
            return(result);
        }
Exemplo n.º 10
0
        [Test] public void TestFilterListEx()
        {
            IResource person   = _storage.NewResource("Person");
            IResource category = CategoryManager.CreateCategory("Test", _categoryManager.RootCategory);
            IResource email    = _storage.NewResource("Email");
            IResource email2   = _storage.NewResource("Email");

            person.AddLink(_propAuthor, email);
            _categoryManager.AddResourceCategory(email2, category);

            IResource workspace = _workspaceManager.CreateWorkspace("Test ");

            _workspaceManager.AddResourceToWorkspace(workspace, person);
            _workspaceManager.AddResourceToWorkspace(workspace, category);
            IResourceList resList = _workspaceManager.GetFilterList(workspace);

            Assert.AreEqual(4, resList.Count);
            Assert.IsTrue(resList.IndexOf(email) >= 0);
            Assert.IsTrue(resList.IndexOf(email2) >= 0);
            Assert.IsTrue(resList.IndexOf(person) >= 0);
            Assert.IsTrue(resList.IndexOf(category) >= 0);
        }
Exemplo n.º 11
0
 //  Proper list consist of either email resources or arbitrary
 //  others if they are proper attachments of emails from this list.
 private bool  ListOfMailsOrLinkedAttachments(IResourceList list)
 {
     foreach (IResource res in list)
     {
         if (res.Type != STR.Email)
         {
             IResource parent = res.GetLinkProp(PROP.Attachment);
             if (parent == null || list.IndexOf(parent) == -1)
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Exemplo n.º 12
0
 public void SubscribeToGroup(string group)
 {
     if (!Resource.IsDeleted)
     {
         if (ContainsGroup(group))
         {
             IResourceList servers = Core.ResourceStore.FindResources(
                 null, NntpPlugin._propSubscribedNewsgroupList, group);
             if (servers.IndexOf(Resource) < 0)
             {
                 Resource.GetStringListProp(NntpPlugin._propSubscribedNewsgroupList).Add(group);
             }
         }
     }
 }
Exemplo n.º 13
0
        private static void  LinkRuleToDependents(IResource rule, IResourceList folders)
        {
            int           linkId      = Core.ResourceStore.PropTypes["ExpirationRuleLink"].Id;
            IResourceList prevFolders = rule.GetLinksOfType(null, linkId);

            foreach (IResource folder in folders)
            {
                new ResourceProxy(folder).SetProp("ExpirationRuleLink", rule);
            }
            for (int i = 0; i < prevFolders.Count; i++)
            {
                if (folders.IndexOf(prevFolders[i].Id) == -1)
                {
                    new ResourceProxy(prevFolders[i]).DeleteLink(linkId, rule);
                }
            }
        }
Exemplo n.º 14
0
        [Test] public void RecursiveFilter()
        {
            IResource category  = CategoryManager.CreateCategory("Category", _categoryManager.RootCategory);
            IResource category2 = CategoryManager.CreateCategory("Category2", category);

            IResource person = _storage.NewResource("Person");

            _categoryManager.AddResourceCategory(person, category2);

            IResource ws = _workspaceManager.CreateWorkspace("WS");

            _workspaceManager.AddResourceToWorkspaceRecursive(ws, category);

            IResourceList wsList = _workspaceManager.GetFilterList(ws);

            Assert.AreEqual(3, wsList.Count);
            Assert.IsTrue(wsList.IndexOf(person) >= 0);
        }
Exemplo n.º 15
0
        private static bool  CheckExpirationExceptions(IResourceList exceptions)
        {
            if (exceptions.IndexOf(Core.FilterRegistry.Std.ResourceIsFlagged) != -1)
            {
                exceptions = exceptions.Minus(Core.FilterRegistry.Std.ResourceIsFlagged.ToResourceList());
                exceptions = exceptions.Minus(Core.FilterRegistry.Std.ResourceIsAnnotated.ToResourceList());
            }
            exceptions = exceptions.Minus(Core.FilterRegistry.Std.ResourceIsCategorized.ToResourceList());
            exceptions = exceptions.Minus(Core.FilterRegistry.Std.ResourceIsUnread.ToResourceList());

            if (exceptions.Count == 1)
            {
                IResource cond     = exceptions[0];
                IResource template = cond.GetLinkProp("TemplateLink");
                if (template != null && template.Id == Core.FilterRegistry.Std.ReceivedInTheTimeSpanX.Id)
                {
                    string   text   = EditTimeSpanConditionForm.Condition2Text(cond);
                    string[] fields = text.Split(' ');
                    return(fields[0].ToLower() == "last");
                }
            }

            return(false);
        }
Exemplo n.º 16
0
        public bool ContainsGroup(string group)
        {
            IResourceList servers = Core.ResourceStore.FindResources(null, NntpPlugin._propNewsgroupList, group);

            return(servers.IndexOf(Resource) >= 0);
        }
Exemplo n.º 17
0
        //  Construct list of rules which can be applied to the requested
        //  resource list.
        private void  ConstructApplicableRulesList(int optionOrder)
        {
            string[]      requestedTypes;
            IResourceList allRules    = Core.ResourceStore.FindResourcesWithProp(FilterManagerProps.RuleResName, "IsActionFilter");
            IResourceList activeRules = Core.ResourceStore.EmptyResourceList;

            //  Collect all rules which are checked
            IResourceList checkedRules = Core.ResourceStore.EmptyResourceList;

            for (int i = 0; i < listRules.Items.Count; i++)
            {
                if (listRules.GetItemChecked(i))
                {
                    checkedRules = checkedRules.Union(((IResource)listRules.Items[i]).ToResourceList());
                }
            }

            //  First collect rules which are applicable to all resource types.
            foreach (IResource res in allRules)
            {
                if (!res.HasProp("ContentType"))
                {
                    activeRules = activeRules.Union(res.ToResourceList(), true);
                }
            }
            IResourceList restRules = allRules.Minus(activeRules);

            //-----------------------------------------------------------------
            if (optionOrder == 0)  //  Selected resources
            {
                requestedTypes = ResourceTypeHelper.GetUnderlyingResourceTypes(SelectedResourcesInBrowser);
                UpgradeList(restRules, ref activeRules, requestedTypes);
            }
            else
            if (optionOrder == 1)  //  OwnerResource
            {
                IResourceList list = Core.ResourceBrowser.VisibleResources;
                requestedTypes = ResourceTypeHelper.GetUnderlyingResourceTypes(list);

                UpgradeList(restRules, ref activeRules, requestedTypes);
            }
            else
            if (optionOrder == 2)  //  Tab
            {
                requestedTypes = Core.TabManager.CurrentTab.GetResourceTypes();
                UpgradeList(restRules, ref activeRules, requestedTypes);
            }
            else
            {
                activeRules = allRules;
            }

            activeRules.Sort(new SortSettings(Core.Props.Name, true));

            listRules.Items.Clear();
            foreach (IResource rule in activeRules)
            {
                listRules.Items.Add(rule);
            }

            //  Select those rule which were selected on previous option
            //  if they are present in the new list.
            IResourceList newChecked = checkedRules.Intersect(activeRules);

            for (int i = 0; i < listRules.Items.Count; i++)
            {
                if (newChecked.IndexOf((IResource)listRules.Items[i]) != -1)
                {
                    listRules.SetItemChecked(i, true);
                }
            }
        }
Exemplo n.º 18
0
 public bool FindResourceNode(IResource res)
 {
     return(allStores.IndexOf(res) != -1);
 }
Exemplo n.º 19
0
        private void  InitializeControls(IResource rule)
        {
            comboTimeUnits.Text = "Days";
            _resultRule         = rule;

            if (rule != null)
            {
                IResourceList exceptions = Core.FilterRegistry.GetExceptions(rule);
                if (exceptions.IndexOf(Core.FilterRegistry.Std.ResourceIsFlagged) != -1)
                {
                    checkFlaggedResources.Checked = true;
                    exceptions = exceptions.Minus(Core.FilterRegistry.Std.ResourceIsFlagged.ToResourceList());
                    exceptions = exceptions.Minus(Core.FilterRegistry.Std.ResourceIsAnnotated.ToResourceList());
                }
                if (exceptions.IndexOf(Core.FilterRegistry.Std.ResourceIsCategorized) != -1)
                {
                    checkCategorizedResources.Checked = true;
                    exceptions = exceptions.Minus(Core.FilterRegistry.Std.ResourceIsCategorized.ToResourceList());
                }
                if (exceptions.IndexOf(Core.FilterRegistry.Std.ResourceIsUnread) != -1)
                {
                    checkUnreadResources.Checked = true;
                    exceptions = exceptions.Minus(Core.FilterRegistry.Std.ResourceIsUnread.ToResourceList());
                }

                if (exceptions.Count > 0)
                {
                    InitializeTimeUnitsCombo(exceptions[0]);
                    radioOlder.Checked = true;
                    radioCount.Checked = numericCountResources.Enabled = false;
                }
                else
                {
                    int count = rule.GetIntProp("CountRestriction");
                    numericCountResources.Value = count;
                    radioCount.Checked          = true;
                    radioOlder.Checked          = numericOlderValue.Enabled = false;
                    comboTimeUnits.Enabled      = false;
                }

                //-----------------------------------------------------------------
                IResourceList actions = Core.FilterRegistry.GetActions(rule);
                if (actions.IndexOf(Core.FilterRegistry.Std.DeleteResourceAction) != -1)
                {
                    checkDeleteResources.Checked = true;
                    if (checkDeleteResources.Checked)
                    {
                        checkDeleteRelatedContacts.Checked = rule.HasProp("DeleteRelatedContact");
                    }
                }
                if (actions.IndexOf(Core.FilterRegistry.Std.MarkResourceAsReadAction) != -1)
                {
                    checkMarkRead.Checked = true;
                }
            }
            else
            {
                radioOlder.Checked = true;
                radioCount.Checked = numericCountResources.Enabled = false;
            }
        }
Exemplo n.º 20
0
        private void DoMergeEvents()
        {
            if (!_mergeEvents)
            {
                return;
            }

            // C0 A1 A2 A3 R1

            for (int i = _events.Count - 1; i >= 0; i--)
            {
                //             i
                // C0 A1 A2 A3 R1

                ResourceListEvent ev = (ResourceListEvent)_events [i];
                if (ev.ResourceList != _resList)
                {
                    _events.RemoveAt(i);
                    continue;
                }

                if (ev.EventType == EventType.Remove)
                {
                    bool discardRemove = false;

                    // Remove eats all previous events with the same resource, up to and including the Add

                    //          j  i
                    // C0 A1 A2 A3 R1

                    for (int j = i - 1; j >= 0; j--)
                    {
                        ResourceListEvent ev2 = (ResourceListEvent)_events [j];
                        if (ev2.ResourceID == ev.ResourceID)
                        {
                            //    j        i
                            // C0 A1 A2 A3 R1

                            _events.RemoveAt(j);

                            //    j        i
                            // C0 A2 A3 R1

                            i--;

                            //    j     i
                            // C0 A2 A3 R1

                            if (ev2.EventType == EventType.Add)
                            {
                                // adjust the index of events following the removed Add
                                discardRemove = true;

                                //    jk     i
                                // C0 A2 A3 R1

                                int maxAdjustIndex = ev2.Index;

                                for (int k = j; k <= i; k++)
                                {
                                    ResourceListEvent ev3 = (ResourceListEvent)_events [k];
                                    if (ev3.EventType == EventType.Remove && ev3.Index < maxAdjustIndex)
                                    {
                                        maxAdjustIndex--;
                                        if (maxAdjustIndex < 0)
                                        {
                                            throw new ApplicationException("ResourceList event queue internal error: negative maxAdjustIndex");
                                        }
                                    }
                                    else if (ev3.Index > maxAdjustIndex)
                                    {
                                        if (ev3.Index <= 0)
                                        {
                                            throw new ApplicationException("ResourceList event queue internal error: negative index on" + ev.ToString());
                                        }
                                        ev3.SetIndex(ev3.Index - 1);
                                    }
                                }
                                //    j     ik
                                // C0 A1 A2 R1
                                break;
                            }
                        }
                    }
                    if (discardRemove)
                    {
                        Debug.Assert(_events [i] == ev);
                        _events.RemoveAt(i);
                        continue;
                    }
                    //    j     ik
                    // C0 A1 A2
                }
                else if (ev.EventType == EventType.Change)
                {
                    bool discardChange = false;
                    for (int j = i - 1; j >= 0; j--)
                    {
                        ResourceListEvent ev2 = (ResourceListEvent)_events [j];
                        if (ev2.ResourceID == ev.ResourceID)
                        {
                            if (ev2.EventType == EventType.Change)
                            {
                                ev2.SetChangeSet(ev.ChangeSet.Merge(ev2.ChangeSet));
                            }
                            discardChange = true;
                            break;
                        }
                    }
                    if (discardChange)
                    {
                        Debug.Assert(_events [i] == ev);
                        _events.RemoveAt(i);
                        continue;
                    }
                }

                if (ev.EventType != EventType.Remove)
                {
                    int index = _resList.IndexOf(ev.ResourceID);
                    if (index < 0)
                    {
                        throw new InvalidOperationException("ResourceListEventQueue internal error: resource " +
                                                            ev.ResourceID + " not found in list (event" + ev.ToString() + ")");
                    }
                    ev.SetListIndex(index);
                }
            }

            _needMerge = false;
        }