/// <summary>
        /// Get all operators from user input text.
        /// </summary>
        /// <param name="userInputText"> User input text. </param>
        /// <returns> List of all operators order by priority. </returns>
        public static List <IOperator> GetAllOperators(string userInputText)
        {
            var operatorExtractor = new OperatorExtractor(userInputText);
            var operators         = new List <IOperator>();

            for (
                IOperator theOperator = operatorExtractor.GetNextOperator();
                theOperator != null;
                theOperator = operatorExtractor.GetNextOperator()
                )
            {
                operators.Add(theOperator);
            }
            return(operators.OrderBy(op => op.Priority).ToList());
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            IUserInterface ui            = new ConsoleUI();
            var            dataPath      = ui.UserDataPath;
            var            fileReader    = new FileReader(dataPath);
            var            directoryData = fileReader.GetRawData();
            var            database      = new SqlDatabaseSqlServer(sqlSqeverServerName, sqlSqeverDatabaseName);

            foreach (var pair in directoryData)
            {
                database.InsertDataList(Tokenizer.GetAllTokens(pair.Key, pair.Value));
            }
            var userInputText = ui.UserInput;
            var operators     = OperatorExtractor.GetAllOperators(userInputText);
            var result        = new Searcher().RunOperators(operators, database);

            ui.ShowOutput(result);
        }