コード例 #1
0
        private void InvokeAction(CCommand cmd)
        {
            var dres = cmd.InvokeAction(Params.Array.ToArray());

            if (!string.IsNullOrEmpty(dres.Message))
            {
                if (dres.Result == CDebugResult.Warn)
                {
                    LogFramework.WriteNewLog(dres.Message, dres.CClass, dres.Object, dres.Action, LogEnums.ResultCode.WarnMethod, dres.CColor);
                    Beep(800, 100);
                }
                else if (dres.Result == CDebugResult.Error)
                {
                    LogFramework.WriteNewLog(dres.Message, dres.CClass, dres.Object, dres.Action, LogEnums.ResultCode.ErrorMethod, dres.CColor);
                    Beep(85, 300);
                }
                else if (dres.Result == CDebugResult.OK)
                {
                    LogFramework.WriteNewLog(dres.Message, dres.CClass, dres.Object, dres.Action, LogEnums.ResultCode.OKMethod, dres.CColor);
                    Beep(3500, 100);
                }
                else if (dres.Result == CDebugResult.Working)
                {
                    LogFramework.WriteNewLog(dres.Message, dres.CClass, dres.Object, dres.Action, LogEnums.ResultCode.WorkingMethod, dres.CColor);
                }
            }
        }
コード例 #2
0
 public ConsoleAPI(CCommand cmd)
 {
     MaxParams = 0;
     if (cmd.Params != null && cmd.Params.Length > 0)
     {
         MaxParams = cmd.Params.Length;
     }
     //ConsoleDebug.Commands.Add(cmd);
     Command = cmd;
     CClass.CheckCreateAdd(this, ConsoleDebug.CMDAPI);
 }
コード例 #3
0
        internal static CCommand[] GetCCommandList()
        {
            var cclass = CClass.GetCClass(CMD);
            var objs   = cclass.Objects;

            CCommand[] cmds = new CCommand[objs.Length];
            for (var i = 0; i != cmds.Length; i++)
            {
                cmds[i] = (CCommand)objs[i];
            }
            return(cmds);
        }
コード例 #4
0
        public ConsoleDebug()
        {
            //Commands = new ExtraArray<CCommand>(Array.Empty<CCommand>());

            CCommand.SNew(CommandActions.Help, "help", "Default", true, "Showing command list or using as command helper", "Command");
            CCommand.SNew(CommandActions.Exit, "exit", "Default", false, "Stopping current process");
            CCommand.SNew(CommandActions.DebugBeep, "beep", "Default", true, "Debug beep, returns value", "State");
            CCommand.SNew(CommandActions.ClearConsole, "clear", "Default", false, "Clears console bufer");

            CCommand.SNew(CommandActions.PackFileInPkg, "pkgpack", "PackageManager", false, "Packing file into package", "File path", "PKG name");
            CCommand.SNew(CommandActions.UnpackFileInPkg, "pkgunpack", "PackageManager", false, "Unpacking file into folder", "Filename", "PKG name", "Folder path");
            CCommand.SNew(CommandActions.CreatePKG, "pkgcreate", "PackageManager", false, "Creating new pkg in pkgmgr", "PKG name");
            CCommand.SNew(CommandActions.ImportPKG, "pkgimport", "PackageManager", false, "Importing pkg from folder", "File path");
            CCommand.SNew(CommandActions.ExportPKG, "pkgexport", "PackageManager", false, "Exporting pkg into folder", "Folder path", "PKG name");
            Instance = this;
            CClass.CheckCreateAdd(this, nameof(ConsoleDebug));
        }
コード例 #5
0
        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));
            }
        }