示例#1
0
        public static void Toggle(string input) //? Switch a module ON/OFF
        {
            void ToggleList()                   //! Write Activated/Desactivated IModules
            {
                foreach (IModule mod in Module.ModulesList)
                {
                    if (mod.IsActivated)
                    {
                        Shell.WriteLine(ConsoleColor.Green, mod.GetType().Name);
                    }
                    else
                    {
                        Shell.WriteLine(ConsoleColor.Red, mod.GetType().Name);
                    }
                }
            }

            string[] split = input.Split(' ');

            if (split.Length == 1 || (split.Length > 1 && split[1] == "list"))
            {
                ToggleList();
                return;
            }

            if (split.Length < 2)
            {
                Shell.WriteLine("Invalid arguments, please try with \"toggle <module>\"");
            }

            foreach (string str in split) // Support toggling multiple modules at a time
            {
                if (str.Equals("toggle", StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }

                IModule m = Module.GetModule(str);

                if (m == null)
                {
                    Shell.WriteLineError("Module " + str + " don't exist.");
                    return;
                }

                if (!m.IsActivated)
                {
                    m.IsActivated = true;
                    m.Activate();
                    Shell.WriteLine(ConsoleColor.Cyan, "Module " + m.GetType().Name + " activated");
                }
                else
                {
                    m.IsActivated = false;
                    m.Desactivate();
                    Shell.WriteLine(ConsoleColor.Cyan, "Module " + m.GetType().Name + " desactivated");
                }
            }
        }
示例#2
0
        public static void Reload(string input) //? Reload Modules
        {
            string[] args = input.Split(' ');

            if (args.Length < 2) //! Reload all modules
            {
                foreach (IModule module in Module.ModulesList)
                {
                    if (module.IsActivated)
                    {
                        module.Desactivate();
                        module.Activate();
                    }
                }

                Shell.Write(ConsoleColor.DarkCyan, "[Reload] ");
                Shell.WriteLine("All modules have been reloaded");
                Log.SendLog("[Reload] All modules have been reloader");
            }
            else //! Reload specified modules
            {
                foreach (string str in args.SubArray(1))
                {
                    IModule module = Module.GetModule(str);

                    if (module != null && module.IsActivated)
                    {
                        module.Desactivate();
                        module.Activate();
                        Shell.Write(ConsoleColor.DarkCyan, "[Reload] ");
                        Shell.WriteLine($"Module {module.GetType().Name} reloaded");
                        Log.SendLog($"[Reload] Module {module.GetType().Name} reloaded");
                    }
                }
            }
        }