void PluginRequirementCollectionEvents(PluginRequirementCollection collection) { Guid id = Guid.NewGuid(); PluginRequirementCollectionChangingEventArgs lastChanging = null; PluginRequirementCollectionChangedEventArgs lastChanged = null; int changingCount = 0; int changedCount = 0; collection.Changing += (o, e) => { lastChanging = e; changingCount++; }; collection.Changed += (o, e) => { lastChanged = e; changedCount++; }; // Check add PluginRequirement req = collection.AddOrSet(id, RunningRequirement.MustExistAndRun); Assert.That(changedCount == 1 && changingCount == 1); Assert.That(lastChanging.Action == CK.Core.ChangeStatus.Add); Assert.That(lastChanged.Action == CK.Core.ChangeStatus.Add); Assert.That(lastChanging.Collection == collection); Assert.That(lastChanged.Collection == collection); Assert.That(lastChanging.PluginId == id); Assert.That(lastChanged.PluginId == id); Assert.That(lastChanging.Requirement == RunningRequirement.MustExistAndRun); Assert.That(lastChanged.Requirement == RunningRequirement.MustExistAndRun); changedCount = 0; changingCount = 0; // Check delete : from the collection collection.Remove(id); Assert.That(changedCount == 1 && changingCount == 1); Assert.That(lastChanging.Action == CK.Core.ChangeStatus.Delete); Assert.That(lastChanged.Action == CK.Core.ChangeStatus.Delete); Assert.That(lastChanging.Collection == collection); Assert.That(lastChanged.Collection == collection); Assert.That(lastChanging.PluginId == id); Assert.That(lastChanged.PluginId == id); Assert.That(lastChanging.Requirement == RunningRequirement.MustExistAndRun); Assert.That(lastChanged.Requirement == RunningRequirement.MustExistAndRun); changedCount = 0; changingCount = 0; // Check clear collection.Clear(); Assert.That(changedCount == 1 && changingCount == 1); Assert.That(lastChanging.Action == CK.Core.ChangeStatus.ContainerClear); Assert.That(lastChanged.Action == CK.Core.ChangeStatus.ContainerClear); Assert.That(lastChanging.Collection == collection); Assert.That(lastChanged.Collection == collection); Assert.That(lastChanging.PluginId == Guid.Empty); Assert.That(lastChanged.PluginId == Guid.Empty); Assert.That(lastChanging.Requirement == 0); Assert.That(lastChanged.Requirement == 0); }
void PluginRequirementChanged(object sender, PluginRequirementCollectionChangedEventArgs e) { Debug.Assert(_layers.Exists(l => l.PluginRequirements == e.Collection), "The source of the event belongs to our _layers."); if (e.PluginId != Guid.Empty) { Update(e.PluginId); } else { foreach (PluginRequirement p in e.Collection) { Update(p.PluginId); } } }