Ejemplo n.º 1
0
        public static CParameter[] FromLine(string line, int max)
        {
            var lines = CommandActions.GetLine(line).ToList();

            lines.RemoveAt(0);
            List <CParameter> parames = new List <CParameter>();

            for (var i = 0; i != max; i++)
            {
                parames.Add(new CParameter("", lines[i]));
            }
            return(parames.ToArray());
        }
Ejemplo n.º 2
0
        public static CParameter[] FromLine(string line)
        {
            var lines = CommandActions.GetLine(line).ToList();

            lines.RemoveAt(0);
            List <CParameter> parames = new List <CParameter>();

            if (lines.Count > 1)
            {
                for (var i = 0; i != lines.Count; i++)
                {
                    parames.Add(new CParameter("", lines[i]));
                }
            }
            else
            {
                parames.Add(new CParameter("", lines[0]));
            }
            return(parames.ToArray());
        }
Ejemplo n.º 3
0
        /*
         * internal void Add(ConsoleDebug.ActionResult action, string cline, string cl, bool uwp = false, string description = null)
         * {
         *  Commands.Add(CCommand.New(action, cline, cl, uwp, description));
         * }
         * internal void SAdd(ConsoleDebug.ActionResult action, string cline, string cl, bool uwp = false, string description = null)
         * {
         *  Commands.Add(CCommand.SNew(action, cline, cl, uwp, description));
         * }
         */
        public void WaitCommand(string cline)
        {
            bool normal = true;

            if (string.IsNullOrEmpty(cline))
            {
                normal = false;
            }

            if (normal)
            {
                if (cline[0] == ' ')
                {
                    for (var i = 1; i != cline.Length; i++)
                    {
                        if (cline[i] != ' ')
                        {
                            cline = cline.Remove(0, i);
                            break;
                        }
                    }
                }
                if (string.IsNullOrEmpty(cline))
                {
                    normal = false;
                }
            }

            bool finded = false;

            if (normal)
            {
                string clinesp = cline;
                //var spacep = clinesp.Length - 1;
                for (var i = clinesp.Length - 1; i != 0; i--)
                {
                    if (clinesp[i] == ' ')
                    {
                        clinesp = clinesp.Remove(i, 1);
                    }
                    else
                    {
                        break;
                    }
                }
                string c      = clinesp;
                var    clines = CommandActions.GetLine(clinesp);
                if (!Params.IsNull())
                {
                    Params.Clear();
                }
                if (clines.Length > 1)
                {
                    Params = new ExtraArray <CParameter>(CParameter.FromLine(clinesp).ToArray().AsMemory());

                    var cc = clinesp.Split(' ');
                    c = cc[0];
                }
                foreach (var item in GetCCommandList())
                {
                    if (item.CommandLine == c)
                    {
                        finded = true;
                        if (Params.Count == item.Params.Length)
                        {
                            InvokeAction(item);
                        }
                        else
                        {
                            if (item.Params.Length > 0 && !item.UseWithoutParams)
                            {
                                var ot = $"";
                                foreach (var item1 in item.Params)
                                {
                                    ot += $" <{item1}>";
                                }
                                Beep(800, 100);
                                LogFramework.WriteNewLog($"Instruction of {item.CommandLine}:{ot}.", CClass, this, null, LogEnums.ResultCode.WarnMethod);
                            }
                            else if (item.Params.Length > 0 && item.UseWithoutParams)
                            {
                                InvokeAction(item);
                            }
                            else
                            {
                                Beep(800, 100);
                                LogFramework.WriteNewLog($"{item.CommandLine}: using without parameters.", CClass, this, null, LogEnums.ResultCode.WarnMethod);
                            }
                        }
                    }
                }
            }
            if (!finded)
            {
                LogFramework.WriteNewLog("Unknown command.", CClass, this, null, LogEnums.ResultCode.ErrorMethod);
                Beep(85, 300);
            }
        }