public JsonMappingCompoundTo(
            IExecutionEnvironment env,
            JsonMappingTo compound)
        {
            var env1 = env;

            Compound    = compound;
            Evaluations = new List <JsonMappingEvaluated>();

            if (!IsCompound)
            {
                Evaluations.Add(new JsonMappingEvaluated(env1, compound.SourceName));
            }
            else
            {
                Evaluations = FsInteropFunctions.ParseLanguageExpression(Compound.SourceName, 0).IsRecordSetNameExpression ? new List <JsonMappingEvaluated> {
                    new JsonMappingEvaluated(env1, Compound.SourceName)
                } : ((LanguageAST.LanguageExpression.ComplexExpression)FsInteropFunctions.ParseLanguageExpression(Compound.SourceName, 0))
                .Item
                .Where(x => !x.IsWarewolfAtomExpression)
                .Select(FsInteropFunctions.LanguageExpressionToString)
                .Select(x =>
                        new JsonMappingEvaluated(env1, x))
                .ToList();
            }
        }
Exemple #2
0
        public void Given_ParseLanguageExpression_Should()
        {
            const string personChildName    = "[[@Person.Child.Name]]";
            var          languageExpression = FsInteropFunctions.ParseLanguageExpression(personChildName, 0);

            Assert.IsNotNull(languageExpression);
        }
Exemple #3
0
 string CalculateDestinationNameFromSourceName(string sourceName)
 {
     LanguageAST.LanguageExpression parsed = FsInteropFunctions.ParseLanguageExpression(sourceName, 0);
     if (parsed.IsScalarExpression)
     {
         return(((LanguageAST.LanguageExpression.ScalarExpression)parsed).Item);
     }
     if (parsed.IsRecordSetExpression)
     {
         return(((LanguageAST.LanguageExpression.RecordSetExpression)parsed).Item.Column);
     }
     return(((LanguageAST.LanguageExpression.RecordSetNameExpression)parsed).Item.Name);
 }
#pragma warning disable S1541 // Methods and properties should not be too complex
        public static string ValidateInput(string sourceName)
#pragma warning restore S1541 // Methods and properties should not be too complex
        {
            try
            {
                var parsed = FsInteropFunctions.ParseLanguageExpression(sourceName, 0);
                if (parsed.IsComplexExpression)
                {
                    var complex = (LanguageAST.LanguageExpression.ComplexExpression)parsed;
                    if (complex.Item
                        .Any(x => x.IsRecordSetNameExpression))
                    {
                        return(ErrorResource.CannotCommaSeperateRecordset);
                    }
                    if (complex.Item.Count() < 3 ||
                        complex.Item.Count() % 2 != 1 ||

                        !Enumerable.Range(1, complex.Item.Count() - 1)
                        .Where(i => i % 2 == 1)
                        .Select(i =>

                                FsInteropFunctions.LanguageExpressionToString(
                                    complex.Item.ElementAt(i)
                                    ) == ",")
                        .Aggregate((a, b) => a && b))

                    {
                        return(ErrorResource.ExpressionMustBeCommaSeperated);
                    }
                }
                else
                {
                    if (!parsed.IsRecordSetNameExpression &&
                        !parsed.IsRecordSetExpression &&
                        !parsed.IsScalarExpression &&
                        !parsed.IsWarewolfAtomExpression)
                    {
                        return(ErrorResource.OnlyScalarRecordsetCommaSeperated);
                    }
                }
            }
            catch (Exception)
            {
                return(ErrorResource.UnableToParseSourceName);
            }
            return(null);
        }
Exemple #5
0
        public static string ValidateInput(string sourceName)
        {
            try
            {
                var parsed = FsInteropFunctions.ParseLanguageExpression(sourceName, 0);
                if (parsed.IsComplexExpression)
                {
                    var complex = (LanguageAST.LanguageExpression.ComplexExpression)parsed;
                    if (complex.Item
                        .Any(x => x.IsRecordSetNameExpression))
                    {
                        return(ErrorResource.CannotCommaSeperateRecordset);
                    }
                    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 =>

                                FsInteropFunctions.LanguageExpressionToString(
                                    complex.Item.ElementAt(i)
                                    ) == ",")
                        .Aggregate((a, b) => a && b))
                    // ReSharper restore MaximumChainedReferences
                    {
                        return(ErrorResource.ExpressionMustBeCommaSeperated);
                    }
                }
                else if (!parsed.IsRecordSetNameExpression &&
                         !parsed.IsRecordSetExpression &&
                         !parsed.IsScalarExpression &&
                         !parsed.IsWarewolfAtomExpression)
                {
                    return(ErrorResource.OnlyScalarRecordsetCommaSeperated);
                }
            }
            catch (Exception)
            {
                return(ErrorResource.UnableToParseSourceName);
            }
            return(null);
        }
Exemple #6
0
        public JsonMappingCompoundTo(
            IExecutionEnvironment env,
            JsonMappingTo compound)
        {
            var env1 = env;

            Compound    = compound;
            Evaluations = new List <JsonMappingEvaluated>();

            if (!IsCompound)
            {
                Evaluations.Add(new JsonMappingEvaluated(env1, compound.SourceName));
            }
            else
            {
                if (FsInteropFunctions.ParseLanguageExpression(Compound.SourceName, 0).IsRecordSetNameExpression)
                {
                    Evaluations = new List <JsonMappingEvaluated> {
                        new JsonMappingEvaluated(env1, Compound.SourceName)
                    };
                }
                else
                {
                    // we know this is a comma seperated list of expressions
                    Evaluations =
                        // ReSharper disable MaximumChainedReferences
                        ((LanguageAST.LanguageExpression.ComplexExpression)FsInteropFunctions.ParseLanguageExpression(Compound.SourceName, 0))
                        .Item
                        .Where(x => !x.IsWarewolfAtomExpression)
                        .Select(FsInteropFunctions.LanguageExpressionToString)
                        .Select(x =>
                                new JsonMappingEvaluated(env1, x))
                        .ToList();
                }         // ReSharper restore MaximumChainedReferences
            }
        }