Exemplo n.º 1
0
        /// <summary>
        /// Creates a List of plugins from a manually created name chain.
        /// </summary>
        /// <param name="names">The names of the plugins that are specified in the chain</param>
        /// <param name="path">File Path of the compiled assembly</param>
        /// <returns></returns>
        private List <AbstractPlugin> ProcessPluginChain(string[] names, string path)
        {
            List <AbstractPlugin> ret = new List <AbstractPlugin>();

            Logger.Log(PPLogType.Log, Verbosity.Level4, "Loading {0} in file {1}",
                       names == null ? "all plugins" : names.Unpack(", "), path);

            if (names == null)
            {
                ret.AddRange(pluginManager.FromFile(path));
            }
            else
            {
                List <AbstractPlugin> plugins = pluginManager.FromFile(path);
                for (int i = 0; i < names.Length; i++)
                {
                    for (int j = 0; j < plugins.Count; j++)
                    {
                        if (plugins[j].Prefix.Contains(names[i]))
                        {
                            Logger.Log(PPLogType.Log, Verbosity.Level5, "Creating instance of: {0}",
                                       plugins[j].GetType().Name);
                            ret.Add(plugins[j]);
                        }
                    }
                }
            }

            return(ret);
        }
Exemplo n.º 2
0
        /// <summary>
        /// The command handler that is used for the command --generate-readme
        /// </summary>
        /// <returns>Returns true if the CLI should exit after this command</returns>
        private bool ReadmeCommandHandler()
        {
            if (ReadmeArgs.Length == 2)
            {
                if (ReadmeArgs[0] == "self")
                {
                    Logger.Log(PPLogType.Log, Verbosity.Level1, "Generating Readme for self.");
                    List <string> ret = PluginExtensions.ToMarkdown(Info).ToList();
                    Logger.Log(PPLogType.Log, Verbosity.Level1, "Writing Readme to file: {0}", ReadmeArgs[1]);
                    File.WriteAllLines(ReadmeArgs[1], ret.ToArray());
                    return(true);
                }

                Logger.Log(PPLogType.Log, Verbosity.Level1, "Generating Readme for file: {0}", ReadmeArgs[0]);
                PluginManager.PluginManager pm = new PluginManager.PluginManager();
                List <string> ht = GenerateReadme(pm.FromFile(ReadmeArgs[0]));

                Logger.Log(PPLogType.Log, Verbosity.Level1, "Writing Readme to file: {0}", ReadmeArgs[1]);
                File.WriteAllLines(ReadmeArgs[1], ht.ToArray());
                return(true);
            }

            return(false);
        }