public void StartupPluginLoaderTest()
        {
            CoreStartup start = new CoreStartup("TickZoomTest");

            start.StartCoreServices();
            start.RunInitialization();
            string addInConfig =
                @"<Plugin name        = ""LoaderTests""
       author      = ""Wayne Walter""
       url         = """"
       description = ""TODO: Put description here"">
	
	<Runtime>
		<Import assembly = ""TickZoomLoaderTests.dll""/>
	</Runtime>
	
	<Path name = ""/Tests/Loaders"">
		<Extension id=""MyLoader"" class=""TestLoader""/>
	</Path>
</Plugin>";
            var    reader = new StringReader(addInConfig);
            Plugin plugin = Plugin.Load(reader, ".");

            plugin.Enabled = true;
            PluginTree.InsertPlugin(plugin);
            ModelLoaderInterface loader = (ModelLoaderInterface)PluginTree.BuildItem("/Tests/Loaders/MyLoader", this);

            Assert.IsNotNull(loader);
        }
示例#2
0
            public void Apply(IList items)
            {
                PluginTreeNode node;

                try {
                    node = PluginTree.GetTreeNode(path);
                    foreach (object o in node.BuildChildItems(caller))
                    {
                        items.Add(o);
                    }
                } catch (TreePathNotFoundException) {
                    LoggingService.Error("IncludeDoozer: AddinTree-Path not found: " + path);
                }
            }
示例#3
0
        /// <summary>
        /// Initializes the Plugin system.
        /// This loads the Plugins that were added to the list,
        /// then it executes the <see cref="ICommand">commands</see>
        /// in <c>/Workspace/Autostart</c>.
        /// </summary>
        public void RunInitialization()
        {
            PluginTree.Load(pluginFiles, disabledPlugins);

            // run workspace autostart commands
            LoggingService.Info("Running autostart commands...");
            foreach (ICommand command in PluginTree.BuildItems <ICommand>("/Workspace/Autostart", null, false))
            {
                try {
                    command.Run();
                } catch (Exception ex) {
                    // allow startup to continue if some commands fail
                    LoggingService.Error("Error during autostart: " + ex.Message, ex);
                }
            }
        }
示例#4
0
        /// <summary>
        /// Adds the specified external Plugins to the list of registered external
        /// Plugins.
        /// </summary>
        /// <param name="plugins">
        /// The list of Plugins to add. (use <see cref="Plugin"/> instances
        /// created by <see cref="Plugin.Load(TextReader)"/>).
        /// </param>
        public static void AddExternalPlugins(IList <Plugin> plugins)
        {
            List <string> pluginFiles = new List <string>();
            List <string> disabled    = new List <string>();

            LoadPluginConfiguration(pluginFiles, disabled);

            foreach (Plugin plugin in plugins)
            {
                if (!pluginFiles.Contains(plugin.FileName))
                {
                    pluginFiles.Add(plugin.FileName);
                }
                plugin.Enabled = false;
                plugin.Action  = PluginAction.Install;
                PluginTree.InsertPlugin(plugin);
            }

            SavePluginConfiguration(pluginFiles, disabled);
        }
示例#5
0
        public object BuildItem(object caller, Extension extension, ArrayList subItems)
        {
            string item = extension.Properties["item"];
            string path = extension.Properties["path"];

            if (item != null && item.Length > 0)
            {
                // include item
                return(PluginTree.BuildItem(item, caller));
            }
            else if (path != null && path.Length > 0)
            {
                // include path (=multiple items)
                return(new IncludeReturnItem(caller, path));
            }
            else
            {
                LoggingService.Error("<Include> requires the attribute 'item' (to include one item) or the attribute 'path' (to include multiple items)");
                return(null);
            }
        }
示例#6
0
        /// <summary>
        /// Removes the specified external Plugins from the list of registered external
        /// Plugins.
        /// </summary>
        /// The list of Plugins to remove.
        /// (use external Plugins from the <see cref="PluginTree.Plugins"/> collection).
        public static void RemoveExternalPlugins(IList <Plugin> plugins)
        {
            List <string> pluginFiles = new List <string>();
            List <string> disabled    = new List <string>();

            LoadPluginConfiguration(pluginFiles, disabled);

            foreach (Plugin plugin in plugins)
            {
                foreach (string identity in plugin.Manifest.Identities.Keys)
                {
                    disabled.Remove(identity);
                }
                pluginFiles.Remove(plugin.FileName);
                plugin.Action = PluginAction.Uninstall;
                if (!plugin.Enabled)
                {
                    PluginTree.RemovePlugin(plugin);
                }
            }

            SavePluginConfiguration(pluginFiles, disabled);
        }