public static DResult ClearConsole(params CParameter[] Params)
        {
            Console.Clear();
            var mes = "Console buffer cleared.";

            return(DResult.C(CDebugResult.OK, mes, ClearConsole, ConsoleDebug.CClass, ConsoleDebug.Instance));
        }
        public static DResult ImportPKG(params CParameter[] Params)
        {
            var filepath = ConsoleDebug.Params[0].Value.ToString();

            PackageManager.Instance.Import(filepath);
            return(DResult.C(CDebugResult.OK, "", ImportPKG, ConsoleDebug.CClass, ConsoleDebug.Instance));
        }
        public static DResult Exit(params CParameter[] Params)
        {
            var mes = "Exiting...";

            Environment.Exit(0);
            return(DResult.C(CDebugResult.OK, mes, Exit, ConsoleDebug.CClass, ConsoleDebug.Instance));
        }
        public static DResult ExportPKG(params CParameter[] Params)
        {
            var folderpath = ConsoleDebug.Params[0].Value.ToString();
            var pkgname    = ConsoleDebug.Params[1].Value.ToString();

            PackageManager.Instance.Export(pkgname, folderpath);
            return(DResult.C(CDebugResult.OK, "", ExportPKG, ConsoleDebug.CClass, ConsoleDebug.Instance));
        }
        public static DResult PackFileInPkg(params CParameter[] Params)
        {
            var fpath   = ConsoleDebug.Params[0].Value.ToString();
            var pkgname = ConsoleDebug.Params[1].Value.ToString();
            var sp      = Source.Pack(fpath);

            PackageManager.Instance.AddToPkg(pkgname, sp);
            return(DResult.C(CDebugResult.OK, "", PackFileInPkg, ConsoleDebug.CClass, ConsoleDebug.Instance));
        }
        public static DResult UnpackFileInPkg(params CParameter[] Params)
        {
            var filename   = ConsoleDebug.Params[0].Value.ToString();
            var pkgname    = ConsoleDebug.Params[1].Value.ToString();
            var folderpath = ConsoleDebug.Params[2].Value.ToString();
            var pp         = PackageManager.Instance.GetPkg(pkgname);

            pp.Unpack(filename, folderpath);
            return(DResult.C(CDebugResult.OK, "", UnpackFileInPkg, ConsoleDebug.CClass, ConsoleDebug.Instance));
        }
        public static DResult CreatePKG(params CParameter[] Params)
        {
            var pkgname = ConsoleDebug.Params[0].Value.ToString();
            var pp      = new ProtectedPackage
            {
                Name = pkgname
            };

            PackageManager.Instance.AddPkg(pp);
            return(DResult.C(CDebugResult.OK, "", CreatePKG, ConsoleDebug.CClass, ConsoleDebug.Instance));
        }
        public static DResult DebugBeep(params CParameter[] Params)
        {
            if (Params.Length > 0)
            {
                var s = Params[0].Value.ToString();
                if (s == "true" || s == "t" || s == "1")
                {
                    ConsoleDebug.BeepSound = true;

                    var mes = "Console Debug beep is enabled.";
                    return(DResult.C(CDebugResult.OK, mes, DebugBeep, ConsoleDebug.CClass, ConsoleDebug.Instance, ConsoleColor.Green));
                }
                else if (s == "false" || s == "f" || s == "0")
                {
                    ConsoleDebug.BeepSound = false;

                    var mes = "Console Debug beep disabled.";
                    return(DResult.C(CDebugResult.OK, mes, DebugBeep, ConsoleDebug.CClass, ConsoleDebug.Instance, ConsoleColor.DarkRed));
                }
                else
                {
                    var mes = "Unknown parameter.";
                    return(DResult.C(CDebugResult.Warn, mes, DebugBeep, ConsoleDebug.CClass, ConsoleDebug.Instance));
                }
            }
            else
            {
                var ok = "";
                if (ConsoleDebug.BeepSound)
                {
                    ok = "enabled";
                }
                else
                {
                    ok = "disabled";
                }

                var mes = $"Console Debug beep {ok}.";
                return(DResult.C(CDebugResult.OK, mes, DebugBeep, ConsoleDebug.CClass, ConsoleDebug.Instance, ConsoleColor.White));
            }

            /*
             * if (!ConsoleDebug.BeepSound)
             * {
             *  LogFramework.WriteNewLog("Console Debug beep enabled.", LogEnums.Tools.ConsoleDebug, DebugBeep, LogEnums.ResultCode.OKMethod, ConsoleColor.Green);
             *  ConsoleDebug.BeepSound = true;
             * }
             * else
             * {
             *  LogFramework.WriteNewLog("Console Debug beep disabled.", LogEnums.Tools.ConsoleDebug, DebugBeep, LogEnums.ResultCode.OKMethod, ConsoleColor.DarkRed);
             *  ConsoleDebug.BeepSound = false;
             * }
             */
        }
        public static DResult Help(params CParameter[] Params)
        {
            if (Params.Length > 0)
            {
                var param = Params[0].Value.ToString();

                /*
                 * for (var i = 0; i != param.Length; i++)
                 * {
                 *  var par = param;
                 *  if (par[i] == ' ')
                 *      param = par.Remove(i, 1);
                 * }
                 */
                bool     finded = false;
                CCommand cc     = null;
                foreach (var item in ConsoleDebug.GetCCommandList())
                {
                    if (item.CommandLine == param)
                    {
                        finded = true;
                        cc     = item;
                        break;
                    }
                }
                if (finded)
                {
                    var ot = "";
                    var s  = "";
                    if (cc.System)
                    {
                        s = "System";
                    }
                    else
                    {
                        s = "Custom";
                    }
                    ot += $"{s} : {cc.CommandLine}";
                    foreach (var item in cc.Params)
                    {
                        ot += $" <{item}>";
                    }
                    ot += $" - {cc.Description}.";
                    return(DResult.C(CDebugResult.OK, ot, Help, ConsoleDebug.CClass, ConsoleDebug.Instance));
                }
                else
                {
                    var mes = "Unknown command in help list.";
                    return(DResult.C(CDebugResult.Warn, mes, Help, ConsoleDebug.CClass, ConsoleDebug.Instance));
                }
            }
            else
            {
                string ot  = "Command list:\n";
                var    cll = new List <String>();
                var    cs  = ConsoleDebug.GetCCommandList();
                for (var j = 0; j != cs.Length; j++)
                {
                    var cl = cs[j].Class;
                    if (cll.Contains(cl))
                    {
                        continue;
                    }
                    for (var i = 0; i != cs.Length; i++)
                    {
                        if (cs[i].Class == cl)
                        {
                            var s = "";
                            if (cs[i].System)
                            {
                                s = "System";
                            }
                            else
                            {
                                s = "Custom";
                            }
                            string val = $"  {s} : {cs[i].Class} : {cs[i].CommandLine} - {cs[i].Description}";
                            if (i - 1 != cs.Length)
                            {
                                ot += "\n";
                            }
                            ot += val;
                        }
                    }
                    if (j - 1 != cs.Length)
                    {
                        ot += "\n";
                    }
                    cll.Add(cl);
                }
                return(DResult.C(CDebugResult.OK, ot, Help, ConsoleDebug.CClass, ConsoleDebug.Instance, ConsoleColor.White));
            }
        }
Beispiel #10
0
        /// <summary>
        /// Load library lists.
        /// </summary>
        public DResult LoadAllLibraries(params CParameter[] paramms)
        {
            LogFramework.WriteNewLog($"Starting manager dynamic & static libraries", CClass, this, LoadAllLibraries, LogEnums.ResultCode.StartingMethod);
            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);

            var mes = $"Manager dynamic & static libraries enabled";

            return(DResult.C(CDebugResult.Working, mes, LoadAllLibraries, CClass, this));

            /*
             * LogFramework.WriteNewLog($"Loading dynamic libraries", LogEnums.Tools.ResourceManager, new Action(LoadAllLibraries), LogEnums.ResultCode.StartingMethod, null);
             * try
             * {
             *  foreach (DynamicLibrary item in DynamicLibraries)
             *  {
             *      LogFramework.WriteNewLog($"Loading {item.Name} v{item.Ver}", LogEnums.Tools.ResourceManager, new Action(LoadAllLibraries), LogEnums.ResultCode.StartingInMethod, null);
             *      try
             *      {
             *          if (!item.Load())
             *              LogFramework.WriteNewLog($"Failed Load {item.Name} v{item.Ver}", LogEnums.Tools.ResourceManager, new Action(LoadAllLibraries), LogEnums.ResultCode.ErrorInMethod, null);
             *      }
             *      catch (Exception e)
             *      {
             *          LogFramework.WriteNewLog($"Failed Load {item.Name} v{item.Ver}", LogEnums.Tools.ResourceManager, new Action(LoadAllLibraries), LogEnums.ResultCode.ErrorInMethod, e);
             *      }
             *      finally
             *      {
             *          LogFramework.WriteNewLog($"Loaded {item.Name} v{item.Ver}", LogEnums.Tools.ResourceManager, new Action(LoadAllLibraries), LogEnums.ResultCode.OKInMethod, null);
             *      }
             *  }
             * }
             * catch (Exception e)
             * {
             *  LogFramework.WriteNewLog($"Failed load dynamic libraries", LogEnums.Tools.ResourceManager, new Action(LoadAllLibraries), LogEnums.ResultCode.ErrorMethod, null);
             * }
             * finally
             * {
             *  LogFramework.WriteNewLog($"Dynamic libraries loaded", LogEnums.Tools.ResourceManager, new Action(LoadAllLibraries), LogEnums.ResultCode.OKMethod, null);
             * }
             *
             * LogFramework.WriteNewLog($"Loading static libraries", LogEnums.Tools.ResourceManager, new Action(LoadAllLibraries), LogEnums.ResultCode.StartingMethod, null);
             * try
             * {
             *  foreach (var item in DynamicLibraries)
             *  {
             *      LogFramework.WriteNewLog($"Loading {item.Name} v{item.Ver}", LogEnums.Tools.ResourceManager, new Action(LoadAllLibraries), LogEnums.ResultCode.StartingInMethod, null);
             *      try
             *      {
             *          AppDomain.CurrentDomain.Load(item.Raw);
             *      }
             *      catch (Exception e)
             *      {
             *          LogFramework.WriteNewLog($"Failed Load {item.Name} v{item.Ver}", LogEnums.Tools.ResourceManager, new Action(LoadAllLibraries), LogEnums.ResultCode.ErrorInMethod, e);
             *      }
             *      finally
             *      {
             *          LogFramework.WriteNewLog($"Loaded {item.Name} v{item.Ver}", LogEnums.Tools.ResourceManager, new Action(LoadAllLibraries), LogEnums.ResultCode.OKInMethod, null);
             *      }
             *  }
             * }
             * catch (Exception e)
             * {
             *  LogFramework.WriteNewLog($"Failed load static libraries", LogEnums.Tools.ResourceManager, new Action(LoadAllLibraries), LogEnums.ResultCode.ErrorMethod, null);
             * }
             * finally
             * {
             *  LogFramework.WriteNewLog($"Static libraries loaded", LogEnums.Tools.ResourceManager, new Action(LoadAllLibraries), LogEnums.ResultCode.OKMethod, null);
             * }
             */
        }