Esempio n. 1
0
        protected override bool TryParse(string[] parts, out Statement statement)
        {
            statement = null;

            var setVar = new SetVarStatement();

            if (parts.Count(p => p.Length > 0) < 3)
                return false;

            if(!string.Equals(parts[0], ":setvar", StringComparison.InvariantCultureIgnoreCase))
                return false;

            setVar.VariableName = parts.Skip(1).First(p => p.Length > 0);

            var value = string.Join(" ", parts.Skip(2));

            if(value.StartsWith("\"") ^ value.EndsWith("\""))
                return false;

            value = value.Trim('\"');

            setVar.VariableValue = value;

            statement = setVar;

            return true;
        }
Esempio n. 2
0
        protected override bool TryGetStatement(Match match, out Statement statement)
        {
            statement = null;

            var setVar = new SetVarStatement
            {
                VariableName = match.Groups["name"].Value
            };

            if(!match.Groups["value"].Success)
                return false;

            var value = match.Groups["value"].Value.Trim();

            if (value.StartsWith("\"") ^ value.EndsWith("\""))
                return false;

            value = value.Trim('\"');

            setVar.VariableValue = value;

            statement = setVar;

            return true;
        }
Esempio n. 3
0
        protected override bool TryGetStatement(Match match, out Statement statement)
        {
            statement = new NotSupportedStatement
            {
                StatementType = _statementType
            };

            return true;
        }
Esempio n. 4
0
        public bool TryParse(string commandLine, out Statement statement)
        {
            statement = null;
            var preparedLine = commandLine.Replace("\t", " ").Trim();

            var match = _regex.Match(preparedLine);

            if (!match.Success)
                return false;

            if (TryGetStatement(match, out statement))
            {
                statement.InitialString = commandLine;
                return true;
            }

            return false;
        }
Esempio n. 5
0
 protected abstract bool TryGetStatement(Match match, out Statement statement);
Esempio n. 6
0
 protected abstract bool TryParse(string[] parts, out Statement statement);
Esempio n. 7
0
        public bool TryParse(string commandLine, out Statement statement)
        {
            var preparedLine = commandLine.Replace("\t", " ").Trim();

            return TryParse(preparedLine.Split(_separator, StringSplitOptions.None), out statement);
        }
Esempio n. 8
0
 protected override bool TryGetStatement(Match match, out Statement statement)
 {
     statement = _factory();
     return statement != null;
 }