void Plugins_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { switch (e.Action) { case System.Collections.Specialized.NotifyCollectionChangedAction.Add: foreach (var i in e.NewItems) { ILivePluginInfo p = (ILivePluginInfo)i; LookupAndBindLivePluginInfoToPlugin(p); } break; case System.Collections.Specialized.NotifyCollectionChangedAction.Move: throw new NotImplementedException(); case System.Collections.Specialized.NotifyCollectionChangedAction.Remove: foreach (var i in e.OldItems) { ILivePluginInfo p = (ILivePluginInfo)i; LookupAndUnbindLivePluginInfoFromPlugin(p); } break; case System.Collections.Specialized.NotifyCollectionChangedAction.Replace: throw new NotImplementedException(); case System.Collections.Specialized.NotifyCollectionChangedAction.Reset: ClearLivePluginInfos(); break; } }
private void LookupAndBindLivePluginInfoToPlugin(ILivePluginInfo info) { Debug.Assert(info.PluginInfo is PluginInfo); LabPluginInfo labPlugin = _labPluginInfos.GetByKey((PluginInfo)info.PluginInfo); labPlugin.LivePluginInfo = info; }
private void LookupAndUnbindLivePluginInfoFromPlugin(ILivePluginInfo info) { Debug.Assert(info.PluginInfo is PluginInfo); bool exists; LabPluginInfo labPlugin = _labPluginInfos.GetByKey((PluginInfo)info.PluginInfo, out exists); if (exists) { labPlugin.LivePluginInfo = null; } }
internal void Bind(ServiceData s, Func <string, LiveServiceInfo> serviceFinder, Func <string, LivePluginInfo> pluginFinder, DelayedPropertyNotification notifier) { var newGeneralization = s.Generalization != null?serviceFinder(s.Generalization.ServiceInfo.ServiceFullName) : null; notifier.Update(this, ref _generalization, newGeneralization, () => Generalization); var familyRunning = s.Family.DynRunningPlugin; Debug.Assert(IsRunning == (familyRunning != null && s.IsGeneralizationOf(familyRunning.Service))); ILivePluginInfo newRunningPlugin = null; if (IsRunning) { newRunningPlugin = pluginFinder(familyRunning.PluginInfo.PluginFullName); } if (_runningPlugin != null) { notifier.Update(this, ref _lastRunningPlugin, _runningPlugin, () => LastRunningPlugin); } notifier.Update(this, ref _runningPlugin, newRunningPlugin, () => RunningPlugin); }
public void ConfigChanged() { /** * +--------+ * |ServiceA+ ------+ * | | | * +---+----+ | * | | * | | * | | * | +---+---*-+ * +---+-----+ |PluginA-2| * |PluginA-1| | | * | | +---------+ * +---------+ */ DiscoveredInfo info = MockInfoFactory.CreateGraph003(); YodiiEngine engine = new YodiiEngine(new YodiiEngineHostMock()); engine.SetDiscoveredInfo(info); engine.Start(); ILiveServiceInfo sA = engine.LiveInfo.FindService("ServiceA"); ILivePluginInfo p1 = engine.LiveInfo.FindPlugin("PluginA-1"); ILivePluginInfo p2 = engine.LiveInfo.FindPlugin("PluginA-2"); Assert.That(sA != null && p1 != null && p2 != null); Assert.That(p1.Capability.CanStart && p2.Capability.CanStart && sA.Capability.CanStart, Is.True); Assert.That(p1.Capability.CanStartWithFullStart && p2.Capability.CanStartWithFullStart && sA.Capability.CanStartWithFullStart, Is.True); Assert.That(p1.Capability.CanStartWithStartRecommended && p2.Capability.CanStartWithStartRecommended && sA.Capability.CanStartWithStartRecommended, Is.True); Assert.That(p1.Capability.CanStartWithStopOptionalAndRunnable && p2.Capability.CanStartWithStopOptionalAndRunnable && sA.Capability.CanStartWithStopOptionalAndRunnable, Is.True); Assert.That(p1.Capability.CanStartWithFullStop && p2.Capability.CanStartWithFullStop && sA.Capability.CanStartWithFullStop, Is.True); HashSet <string> propertyChanged = new HashSet <string>(); p1.PropertyChanged += (s, e) => { Assert.That(s, Is.SameAs(p1)); Assert.That(propertyChanged.Add("p1." + e.PropertyName)); }; p1.Capability.PropertyChanged += (s, e) => { Assert.That(s, Is.SameAs(p1.Capability)); Assert.That(propertyChanged.Add("p1.Capablity." + e.PropertyName)); }; p2.PropertyChanged += (s, e) => { Assert.That(s, Is.SameAs(p2)); Assert.That(propertyChanged.Add("p2." + e.PropertyName)); }; p2.Capability.PropertyChanged += (s, e) => { Assert.That(s, Is.SameAs(p2.Capability)); Assert.That(propertyChanged.Add("p2.Capablity." + e.PropertyName)); }; sA.PropertyChanged += (s, e) => { Assert.That(s, Is.SameAs(sA)); Assert.That(propertyChanged.Add("sA." + e.PropertyName)); }; sA.Capability.PropertyChanged += (s, e) => { Assert.That(s, Is.SameAs(sA.Capability)); Assert.That(propertyChanged.Add("sA.Capablity." + e.PropertyName)); }; IConfigurationLayer config = engine.Configuration.Layers.Create("Default"); config.Items.Add(p1.FullName, ConfigurationStatus.Disabled); Assert.That(p1.Capability.CanStart && p1.Capability.CanStartWithFullStart && p1.Capability.CanStartWithStartRecommended && p1.Capability.CanStartWithStopOptionalAndRunnable && p1.Capability.CanStartWithFullStop, Is.False); Assert.That(p2.Capability.CanStart && sA.Capability.CanStart, Is.True); Assert.That(p2.Capability.CanStartWithFullStart && sA.Capability.CanStartWithFullStart, Is.True); Assert.That(p2.Capability.CanStartWithStartRecommended && sA.Capability.CanStartWithStartRecommended, Is.True); Assert.That(p2.Capability.CanStartWithStopOptionalAndRunnable && sA.Capability.CanStartWithStopOptionalAndRunnable, Is.True); Assert.That(p2.Capability.CanStartWithFullStop && sA.Capability.CanStartWithFullStop, Is.True); CollectionAssert.AreEquivalent(new string[] { "p1.Capablity.CanStart", "p1.Capablity.CanStartWithFullStart", "p1.Capablity.CanStartWithStartRecommended", "p1.Capablity.CanStartWithStopOptionalAndRunnable", "p1.Capablity.CanStartWithFullStop", "p1.DisabledReason", "p1.RunningStatus", "p1.ConfigOriginalStatus", "p1.WantedConfigSolvedStatus", "p1.FinalConfigSolvedStatus" }, propertyChanged); propertyChanged.Clear(); config.Items.Add(p1.FullName, ConfigurationStatus.Optional); CollectionAssert.AreEquivalent(new string[] { "p1.Capablity.CanStart", "p1.Capablity.CanStartWithFullStart", "p1.Capablity.CanStartWithStartRecommended", "p1.Capablity.CanStartWithStopOptionalAndRunnable", "p1.Capablity.CanStartWithFullStop", "p1.DisabledReason", "p1.RunningStatus", "p1.ConfigOriginalStatus", "p1.WantedConfigSolvedStatus", "p1.FinalConfigSolvedStatus" }, propertyChanged); }
private void LookupAndUnbindLivePluginInfoFromPlugin( ILivePluginInfo info ) { Debug.Assert( info.PluginInfo is PluginInfo ); bool exists; LabPluginInfo labPlugin = _labPluginInfos.GetByKey( (PluginInfo)info.PluginInfo, out exists ); if( exists ) labPlugin.LivePluginInfo = null; }
private void LookupAndBindLivePluginInfoToPlugin( ILivePluginInfo info ) { Debug.Assert( info.PluginInfo is PluginInfo ); LabPluginInfo labPlugin = _labPluginInfos.GetByKey( (PluginInfo)info.PluginInfo ); labPlugin.LivePluginInfo = info; }