private OperationResult RunCheckQuery(Query query)
        {
            OperationResult result = new OperationResult(false);

            if (!string.IsNullOrEmpty(query.KeyValue))
            {
                result = _commandRunner.IsMatchKeyValue(query.Paths,
                    query.KeyValue, query.Expected);
            }
            else if (!string.IsNullOrEmpty(query.ConnectionString))
            {
                result = _commandRunner.IsMatchConnectionString(query.Paths,
                    query.ConnectionString, query.Expected);
            }

            return result;
        }
Beispiel #2
0
        public Query ParseQuery(string[] queryStringArray)
        {
            OperationResult validationResult = _queryValidator
                .ValidateQuerySyntax(queryStringArray);

            if (!validationResult.Successful)
            {
                throw new ValidationException(validationResult.Description);
            }

            ECommand command = (ECommand)Enum.Parse(typeof(ECommand), queryStringArray[0]);

            string[] arguments = new string[queryStringArray.Length - 1];
            Array.Copy(queryStringArray, 1, arguments, 0, queryStringArray.Length - 1);

            string[] argumentKeyValuDelimiter = new string[1] { ":\"" };

            Dictionary<string, string> argumentsDict = (from arg in arguments
                                                        let splittedArg = arg.Split(new char[] { ':' }, 2)
                                                        select splittedArg)
                                 .ToDictionary(x => x[0], x => x[1]);

            Query query = new Query();
            query.Command = command;
            query.ConnectionString = GetArgumentFromDictionary(argumentsDict, "connectionString");
            query.Expected = GetArgumentFromDictionary(argumentsDict, "expected");
            query.KeyValue = GetArgumentFromDictionary(argumentsDict, "keyValue");

            string unparsedPathsString = GetArgumentFromDictionary(argumentsDict, "paths");
            List<string> originalPaths = String.IsNullOrWhiteSpace(unparsedPathsString)
                ? new List<string>() { Directory.GetCurrentDirectory() }
                : unparsedPathsString.Split(',').ToList();

            query.Paths = _directoryInfoProcessor.GetQueryPathes(originalPaths);

            return query;
        }
 private OperationResult RunGetQuery(Query query)
 {
     throw new NotImplementedException();
 }