YodiiGraphVertex FindOrCreatePluginVertex(LabPluginInfo plugin) { YodiiGraphVertex pluginVertex = this.Vertices.FirstOrDefault(v => v.LabPluginInfo == plugin); if (plugin == null) { pluginVertex = CreatePluginVertex(plugin); } return(pluginVertex); }
void RemovePluginVertex(LabPluginInfo plugin) { YodiiGraphVertex toRemove = Vertices.Where(v => v.LabPluginInfo == plugin).FirstOrDefault(); plugin.PluginInfo.InternalServiceReferences.CollectionChanged -= ObservableServiceReferences_CollectionChanged; plugin.PluginInfo.PropertyChanged -= PluginInfo_PropertyChanged; if (toRemove != null) { RemoveVertex(toRemove); } }
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; } }
/// <summary> /// Removes a mock plugin info from our collections. /// </summary> /// <param name="pluginInfo">Mock plugin info to remove</param> internal void RemovePlugin(PluginInfo pluginInfo) { if (pluginInfo.Service != null) { pluginInfo.InternalService.InternalImplementations.Remove(pluginInfo); } LabPluginInfo livePlugin = _labPluginInfos.GetByKey(pluginInfo); _labPluginInfos.Remove(livePlugin); _pluginInfos.Remove(pluginInfo); }
/// <summary> /// Creates a new plugin vertex. /// </summary> /// <param name="parentGraph"></param> /// <param name="plugin"></param> internal YodiiGraphVertex(YodiiGraph parentGraph, LabPluginInfo plugin) : this() { Debug.Assert(parentGraph != null); Debug.Assert(plugin != null); _isPlugin = true; _livePlugin = plugin; _parentGraph = parentGraph; _livePlugin.PluginInfo.PropertyChanged += StaticInfo_PropertyChanged; _livePlugin.PropertyChanged += _labPlugin_PropertyChanged; }
/// <summary> /// Creates a lab wrapper item around an existing mock plugin, and adds it to our collection. /// </summary> /// <param name="p">Existing mock plugin</param> private void CreateLabPlugin(PluginInfo p) { LabPluginInfo lp; if (p.Service != null) { p.Service.InternalImplementations.Add(p); LabServiceInfo liveService = _labServiceInfos.GetByKey(p.Service); lp = new LabPluginInfo(p); } else { lp = new LabPluginInfo(p); } _labPluginInfos.Add(lp); }
YodiiGraphVertex CreatePluginVertex(LabPluginInfo livePlugin) { YodiiGraphVertex pluginVertex = new YodiiGraphVertex(this, livePlugin) { ID = this.currentId++ }; this.AddVertex(pluginVertex); livePlugin.PluginInfo.PropertyChanged += PluginInfo_PropertyChanged; if (livePlugin.PluginInfo.Service != null) { YodiiGraphVertex serviceVertex = FindOrCreateServiceVertex(livePlugin.PluginInfo.Service); YodiiGraphEdge serviceEdge = new YodiiGraphEdge(pluginVertex, serviceVertex, YodiiGraphEdgeType.Implementation) { ID = currentId++ }; this.AddEdge(serviceEdge); } foreach (MockServiceReferenceInfo reference in livePlugin.PluginInfo.InternalServiceReferences) { YodiiGraphVertex refVertex = FindOrCreateServiceVertex(reference.Reference); YodiiGraphEdge refEdge = new YodiiGraphEdge(pluginVertex, refVertex, reference) { ID = currentId++ }; this.AddEdge(refEdge); } livePlugin.PluginInfo.InternalServiceReferences.CollectionChanged += ObservableServiceReferences_CollectionChanged; return(pluginVertex); }
YodiiGraphVertex FindOrCreatePluginVertex(IPluginInfo pluginInfo) { LabPluginInfo info = _pluginInfos.Where(p => p.PluginInfo == pluginInfo).First(); return(FindOrCreatePluginVertex(info)); }