コード例 #1
0
        public string ToStar(string expression)
        {
            var exp = EvaluationFunctions.parseLanguageExpression(expression, 0);

            if (exp.IsRecordSetExpression)
            {
                var rec = exp as LanguageAST.LanguageExpression.RecordSetExpression;
                if (rec != null)
                {
                    return($"[[{rec.Item.Name}(*).{rec.Item.Column}]]");
                }
            }

            if (exp.IsRecordSetNameExpression)
            {
                var rec = exp as LanguageAST.LanguageExpression.RecordSetNameExpression;
                if (rec != null)
                {
                    return($"[[{rec.Item.Name}(*)]]");
                }
            }

            if (exp.IsJsonIdentifierExpression)
            {
                var replace = expression.Replace(@"()", @"(*)");
                return(replace);
            }
            return(expression);
        }
コード例 #2
0
        public bool HasRecordSet(string recordsetName)
        {
            var x = EvaluationFunctions.parseLanguageExpression(recordsetName, 0, ShouldTypeCast.Yes);

            if (x.IsRecordSetNameExpression && x is LanguageAST.LanguageExpression.RecordSetNameExpression recsetName)
            {
                return(_env.RecordSets.ContainsKey(recsetName.Item.Name));
            }
            return(false);
        }
コード例 #3
0
        public bool HasRecordSet(string recordsetName)
        {
            var x = EvaluationFunctions.parseLanguageExpression(recordsetName, 0);

            if (x.IsRecordSetNameExpression)
            {
                var recsetName = x as LanguageAST.LanguageExpression.RecordSetNameExpression;
                return(_env.RecordSets.ContainsKey(recsetName?.Item.Name));
            }
            return(false);
        }
コード例 #4
0
 public static bool IsRecordSetName(string a)
 {
     try
     {
         var x = EvaluationFunctions.parseLanguageExpression(a, 0, ShouldTypeCast.Yes);
         return(x.IsRecordSetNameExpression);
     }
     catch (Exception)
     {
         return(false);
     }
 }
コード例 #5
0
 public static bool IsScalar(string assignVar)
 {
     try
     {
         var x = EvaluationFunctions.parseLanguageExpression(assignVar, 0, ShouldTypeCast.Yes);
         return(x.IsScalarExpression);
     }
     catch (Exception)
     {
         return(false);
     }
 }
コード例 #6
0
 public static bool IsRecordsetIdentifier(string assignVar)
 {
     try
     {
         var x = EvaluationFunctions.parseLanguageExpression(assignVar, 0);
         return(x.IsRecordSetExpression);
     }
     catch (Exception)
     {
         return(false);
     }
 }
コード例 #7
0
 private static LanguageAST.LanguageExpression ParseExpression(string a)
 {
     try
     {
         var languageExpression = EvaluationFunctions.parseLanguageExpression(a, 0);
         return(languageExpression);
     }
     catch (Exception)
     {
         //
     }
     return(LanguageAST.LanguageExpression.NewWarewolfAtomExpression(DataStorage.WarewolfAtom.Nothing));
 }
コード例 #8
0
        public static string GetPositionColumnExpression(string recordset)
        {
            var rec = EvaluationFunctions.parseLanguageExpression(recordset, 0);

            if (!rec.IsRecordSetExpression && !rec.IsRecordSetNameExpression)
            {
                return(recordset);
            }
            var recordSetExpression     = rec as LanguageAST.LanguageExpression.RecordSetExpression;
            var recordSetNameExpression = rec as LanguageAST.LanguageExpression.RecordSetNameExpression;
            var index = recordSetExpression?.Item?.Name ?? recordSetNameExpression?.Item?.Name;

            return($"[[{index}(*).{EvaluationFunctions.PositionColumn}]]");
        }
コード例 #9
0
ファイル: AssignTests.cs プロジェクト: Warewolf-ESB/Warewolf
        public void ParseLanguage_RecsetExpression_PassAnUpdate()
        {
            //------------Setup for test--------------------------
            var data = CreateEnvironmentWithData();

            //------------Execute Test---------------------------
            var x = EvaluationFunctions.parseLanguageExpression("[[rec(1)]]", 3, ShouldTypeCast.Yes);

            //------------Assert Results-------------------------
            Assert.AreEqual(x.IsRecordSetNameExpression, true);
            var rec = x as LanguageAST.LanguageExpression.RecordSetNameExpression;

            Assert.IsTrue(rec.Item.Index.IsIntIndex);
        }
コード例 #10
0
        public static string ConvertToIndex(string outputVar, int i)
        {
            var output = EvaluationFunctions.parseLanguageExpression(outputVar, 0, ShouldTypeCast.Yes);

            if (output.IsRecordSetExpression && output is LanguageAST.LanguageExpression.RecordSetExpression recSetExpr)
            {
                var outputidentifier = recSetExpr.Item;
                if (Equals(outputidentifier?.Index, LanguageAST.Index.Star))
                {
                    return($"[[{outputidentifier?.Name}({i}).{outputidentifier?.Column}]]");
                }
            }
            return(outputVar);
        }
コード例 #11
0
        public void ParseLanguage_IndexExpression()
        {
            //------------Setup for test--------------------------
            var data = CreateEnvironmentWithData();

            //------------Execute Test---------------------------
            var x = EvaluationFunctions.parseLanguageExpression("[[rec([[a]]).a]]", 1);

            //------------Assert Results-------------------------
            Assert.AreEqual(x.IsRecordSetExpression, true);
            var rec = x as LanguageAST.LanguageExpression.RecordSetExpression;

            Assert.IsTrue(rec.Item.Index.IsIndexExpression);
        }
コード例 #12
0
        public void ParseLanguage_IndexExpression_PassAnUpdate()
        {
            //------------Setup for test--------------------------
            var data = CreateEnvironmentWithData();

            //------------Execute Test---------------------------
            var x = EvaluationFunctions.parseLanguageExpression("[[rec(1).a]]", 3);

            //------------Assert Results-------------------------
            Assert.AreEqual(x.IsRecordSetExpression, true);
            var rec = x as LanguageAST.LanguageExpression.RecordSetExpression;

            // ReSharper disable once PossibleNullReferenceException
            Assert.IsTrue(rec.Item.Index.IsIntIndex);
        }
コード例 #13
0
 public static bool IsValidVariableExpression(string expression, out string errorMessage, int update)
 {
     errorMessage = string.Empty;
     try
     {
         var x = EvaluationFunctions.parseLanguageExpression(expression, update, ShouldTypeCast.Yes);
         if (x.IsRecordSetExpression || x.IsScalarExpression || x.IsJsonIdentifierExpression ||
             x.IsRecordSetNameExpression)
         {
             return(true);
         }
     }
     catch (Exception e)
     {
         errorMessage = e.Message;
         return(false);
     }
     return(false);
 }
コード例 #14
0
 static void MockConstructorExecution(IDSFDataObject dataObject, IServiceTestStep serviceTestStep, ref PluginExecutionDto pluginExecutionDto)
 {
     if (!string.IsNullOrEmpty(serviceTestStep.StepOutputs?[0].Variable))
     {
         try
         {
             var languageExpression = EvaluationFunctions.parseLanguageExpression(serviceTestStep.StepOutputs?[0].Variable, 0);
             if (languageExpression.IsJsonIdentifierExpression)
             {
                 var jToken = JToken.Parse(serviceTestStep.StepOutputs?[0].Value) as JContainer ?? serviceTestStep.StepOutputs?[0].Value.DeserializeToObject();
                 dataObject.Environment.AddToJsonObjects(serviceTestStep.StepOutputs[0].Variable, jToken);
                 pluginExecutionDto.ObjectString = serviceTestStep.StepOutputs[0].Value;
             }
         }
         catch (Exception e)
         {
             dataObject.Environment.Errors.Add(e.Message);
         }
     }
 }
コード例 #15
0
        public string ToStar(string expression)
        {
            var exp = EvaluationFunctions.parseLanguageExpression(expression, 0, ShouldTypeCast.Yes);

            if (exp.IsRecordSetExpression && exp is LanguageAST.LanguageExpression.RecordSetExpression rec)
            {
                return($"[[{rec.Item.Name}(*).{rec.Item.Column}]]");
            }

            if (exp.IsRecordSetNameExpression && exp is LanguageAST.LanguageExpression.RecordSetNameExpression recNameExp)
            {
                return($"[[{recNameExp.Item.Name}(*)]]");
            }

            if (exp.IsJsonIdentifierExpression)
            {
                var replace = expression.Replace(@"()", @"(*)");
                return(replace);
            }
            return(expression);
        }
コード例 #16
0
        public static string GetPositionColumnExpression(string recordset)
        {
            var rec = EvaluationFunctions.parseLanguageExpression(recordset, 0, ShouldTypeCast.Yes);

            if (!rec.IsRecordSetExpression && !rec.IsRecordSetNameExpression)
            {
                return(recordset);
            }

            if (rec is LanguageAST.LanguageExpression.RecordSetExpression recordSetExpression)
            {
                var index = recordSetExpression.Item?.Name;
                return($"[[{index}(*).{EvaluationFunctions.PositionColumn}]]");
            }
            if (rec is LanguageAST.LanguageExpression.RecordSetNameExpression recordSetNameExpression)
            {
                var index = recordSetNameExpression.Item?.Name;
                return($"[[{index}(*).{EvaluationFunctions.PositionColumn}]]");
            }
            // This is a fail safe
            throw new Exception("Unhandled Recordset LanguageExpression");
        }
コード例 #17
0
 public static LanguageAST.LanguageExpression ParseLanguageExpression(string sourceName, int update)
 {
     return(EvaluationFunctions.parseLanguageExpression(sourceName, update));
 }
コード例 #18
0
 public static LanguageAST.LanguageExpression ParseLanguageExpression(string sourceName, int update) => EvaluationFunctions.parseLanguageExpression(sourceName, update, ShouldTypeCast.Yes);