Esempio n. 1
0
        public static string ValidateInput(string sourceName)
        {
            try
            {
                var parsed = WarewolfDataEvaluationCommon.ParseLanguageExpression(sourceName, 0);
                if (parsed.IsComplexExpression)
                {
                    var complex = (LanguageAST.LanguageExpression.ComplexExpression)parsed;
                    if (complex.Item
                        .Any(x => x.IsRecordSetNameExpression))
                    {
                        return("Cannot specify a Recordset as part of a comma seperated list of expressions");
                    }
                    if (complex.Item.Count() < 3 ||
                        complex.Item.Count() % 2 != 1 ||
                        // ReSharper disable MaximumChainedReferences
                        !Enumerable.Range(1, complex.Item.Count() - 1)
                        .Where(i => i % 2 == 1)
                        .Select(i =>

                                WarewolfDataEvaluationCommon.LanguageExpressionToString(
                                    complex.Item.ElementAt(i)
                                    ) == ",")
                        .Aggregate((a, b) => a && b))
                    // ReSharper restore MaximumChainedReferences
                    {
                        return("Problem with input: expressions must be comma seperated");
                    }
                }
                else if (!parsed.IsRecordSetNameExpression &&
                         !parsed.IsRecordSetExpression &&
                         !parsed.IsScalarExpression &&
                         !parsed.IsWarewolfAtomAtomExpression)
                {
                    return("Can only have a scalar, a RecordSet or a RecordSet with column qualification as input");
                }
            }
            catch (Exception)
            {
                return("Unable to parse the Source Name");
            }
            return(null);
        }