public IPluginBase CreatePlugin(INodeInfo nodeInfo, IPluginHost2 pluginHost) { IPluginBase plugin = null; string assemblyLocation = string.Empty; var isUpToDate = GetAssemblyLocation(nodeInfo, out assemblyLocation); // HACK: pluginHost is null in case of WindowSwitcher/NodeBrowser/etc. Fix this. if (pluginHost != null) { // Mark the node if old assembly was loaded and log warning. if (!isUpToDate) { pluginHost.Status |= StatusCode.HasInvalidData; FLogger.Log(LogType.Warning, string.Format("Plugin of node '{0}' (ID: {1}) is out of date and couldn't be recompiled. Check its source code for errors.", nodeInfo.Username, pluginHost.GetID())); } else { pluginHost.Status &= ~StatusCode.HasInvalidData; } } var assembly = Assembly.LoadFrom(assemblyLocation); //Check if need to start anything before rest is loaded FStartableRegistry.ProcessAssembly(assembly); var type = assembly.GetType(nodeInfo.Arguments); // type can be null if assembly is corrupt or doesn't contain cached node info anymore if (type != null) { var attribute = GetPluginInfoAttributeData(type); if (attribute != null) { var pluginContainer = new PluginContainer( pluginHost as IInternalPluginHost, FIORegistry, FParentContainer, FNodeInfoFactory, this, type, nodeInfo); // We intercept the plugin to manage IOHandlers. plugin = pluginContainer; FPluginContainers[pluginContainer.PluginBase] = pluginContainer; // HACK: FPluginHost is null in case of WindowSwitcher and friends if (pluginHost != null) { AssignOptionalPluginInterfaces(pluginHost as IInternalPluginHost, pluginContainer.PluginBase); } // Send event, clients are not interested in wrapping plugin, so send original here. if (this.PluginCreated != null) { this.PluginCreated(pluginContainer.PluginBase, pluginHost); } } else { var v1Plugin = (IPlugin)assembly.CreateInstance(nodeInfo.Arguments); v1Plugin.SetPluginHost(pluginHost); plugin = v1Plugin; // HACK: FPluginHost is null in case of WindowSwitcher and friends if (pluginHost != null) { AssignOptionalPluginInterfaces(pluginHost as IInternalPluginHost, plugin); } // Send event if (this.PluginCreated != null) { this.PluginCreated(plugin, pluginHost); } } } else { pluginHost.Status |= StatusCode.HasInvalidData; FLogger.Log(LogType.Warning, string.Format("Type '{0}' not found in assembly '{1}'. Failed to create plugin node {2} (ID: {3}).", nodeInfo.Arguments, assembly.FullName, nodeInfo.Username, pluginHost.GetID())); } return(plugin); }
/// <summary> /// issues HDEHost to set a descriptiv name; hack, since Labelpin doesn't work /// </summary> /// <param name="key">string to set</param> private void SetDescName(string key) { string xml = string.Format("<PATCH><NODE id=\"{0}\"><PIN pinname=\"Descriptive Name\" values=\"{1}\"></PIN></NODE></PATCH>", FHost.GetID(), key); FHDE.SendXMLSnippet(FHost.ParentNode.GetNodeInfo().Filename, xml, true); }