示例#1
0
 public Commands()
 {
     Dictionary<string, string> dict = new Dictionary<string, string> {
     {"null", "null"},
     };
     Command db = new Command("null", dict);
     //KeyValuePair r = new KeyValuePair<string, object>("key1", 0);
     //// ListCommand.Add(db);
     //// //Command owner = new Command();
     //// ListCommand.Add(db);
     ////// Command stream = new Command();
     //// ListCommand.Add(db);
     //// //Command com1 = new Command();
     //// ListCommand.Add(db);
     ////// Command com2 = new Command();
     //// ListCommand.Add(db);
 }
 public StreamPipeline UpdatePipeline(StreamPipeline sourcePipeline, Command command)
 {
     return sourcePipeline;
 }
示例#3
0
        public Commands Parse(string query)
        {
            char RazdelitelMain = '.';
            Commands ListParseCommands = new Commands();
            int PrevCom = 0; //какая была предыдущая команда
            Dictionary<string, string> dict = new Dictionary<string, string> {
            {"null", "null"},
            };

            //int SecondCom = 0; //какое слово второе
            //int ThirdCom = 0; //какое слово третье
            //int FourthCom = 0; //какое слово четвертое

            int CountCom = 0; //кол-во записанных слов

            string[] words = query.Split(RazdelitelMain);

            for (int i = 0; i < words.Count(); i++)
            {
                if (DB.Contains(words[i]) && i == 0) //ПРОВЕРЯЕМ НА НАЛИЧИЕ ТАКОЙ БД
                {
                    Command db = new Command(words[i].ToString(), dict);
                    ListParseCommands.ListCommand.Add(db); //добавляем такую БД
                    PrevCom = 0;
                }
                else if (Owner.Contains(words[i]) && PrevCom == 0) //если овнер
                {
                    Command owner = new Command(words[i].ToString(), dict);
                    ListParseCommands.ListCommand.Add(owner); //добавляем такую овнер
                    PrevCom = 1;
                }
                else if ((Stream.Contains(words[i]) && PrevCom == 0) || (Stream.Contains(words[i]) && PrevCom == 1)) //если поток
                {
                    if (PrevCom == 0)
                    {
                        Command owner = new Command(null, dict);
                        ListParseCommands.ListCommand.Add(owner); //добавляем такую овнер
                        Command stream = new Command(words[i].ToString(), dict);
                        ListParseCommands.ListCommand.Add(stream); //добавляем такую поток
                        PrevCom = 2;
                    }
                    else if (PrevCom == 1)
                    {
                        Command stream = new Command(words[i].ToString(), dict);
                        ListParseCommands.ListCommand.Add(stream); //добавляем такой поток
                        PrevCom = 2;
                    }
                }
                else if ((FindCommand(words[i]) && PrevCom == 0) || (FindCommand(words[i]) && PrevCom == 1) || (FindCommand(words[i]) && PrevCom == 2)) //если первая команда
                {
                    if (PrevCom == 0) //после БД
                    {
                        Command owner = new Command(null, dict);
                        ListParseCommands.ListCommand.Add(owner); //добавляем такой овнер
                        Command stream = new Command(null, dict);
                        ListParseCommands.ListCommand.Add(stream); //добавляем такой поток
                        char Razdelitel = '(';
                        string[] temp_words = words[i].ToString().Split(Razdelitel);
                        if (temp_words[0] == "SAVE" || temp_words[0] == "KILL")
                        {
                            Command command1 = new Command(temp_words[0], null);
                            ListParseCommands.ListCommand.Add(command1); //добавляем такую команду
                        }
                        else
                        {
                            Dictionary<string, string> readyCommands = SplitCommand(temp_words[1]);
                            Command command1 = new Command(temp_words[0], readyCommands);
                            ListParseCommands.ListCommand.Add(command1); //добавляем такую команду
                        }
                        PrevCom = 3;
                    }
                    else if (PrevCom == 1) //после овнера
                    {
                        Command stream = new Command(null, dict);
                        ListParseCommands.ListCommand.Add(stream); //добавляем такую овнер
                        char Razdelitel = '(';
                        string[] temp_words = words[i].ToString().Split(Razdelitel);
                        Dictionary<string, string> readyCommands = SplitCommand(temp_words[1]);
                        Command command1 = new Command(temp_words[0], readyCommands);
                        ListParseCommands.ListCommand.Add(command1); //добавляем такую поток
                        PrevCom = 3;
                    }
                    else if (PrevCom == 2) //после потока
                    {
                        if (words[i] == "SAVE" || words[i] == "KILL")
                        {
                            Command command1 = new Command(words[i], dict);
                            ListParseCommands.ListCommand.Add(command1); //добавляем такую поток
                            return ListParseCommands;
                        }
                        else
                        {
                            char Razdelitel = '(';
                            string[] temp_words = words[i].ToString().Split(Razdelitel);
                            Dictionary<string, string> readyCommands = SplitCommand(temp_words[1]);
                            Command command1 = new Command(temp_words[0], readyCommands);
                            ListParseCommands.ListCommand.Add(command1); //добавляем такую поток
                            PrevCom = 3;
                        }
                    }
                }
                else if ((FindCommand(words[i]) && PrevCom == 3)) //если вторая команда
                {
                    char Razdelitel = '(';
                    string[] temp_words = words[i].ToString().Split(Razdelitel);
                    Dictionary<string, string> readyCommands = SplitCommand(temp_words[1]);
                    Command command2 = new Command(temp_words[0], readyCommands);
                    ListParseCommands.ListCommand.Add(command2); //добавляем такую поток
                    PrevCom = 4;
                }
                //else return null;
                else if (i != 5)
                    return null;
            }
            return ListParseCommands;
            //return null;
        }