当前位置: 首页>>代码示例>>C#>>正文


C# Processor.Evaluate方法代码示例

本文整理汇总了C#中Processor.Evaluate方法的典型用法代码示例。如果您正苦于以下问题:C# Processor.Evaluate方法的具体用法?C# Processor.Evaluate怎么用?C# Processor.Evaluate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Processor的用法示例。


在下文中一共展示了Processor.Evaluate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BasicEvaluate

        public void BasicEvaluate()
        {
            var processor = new Processor();

            var result = processor.Evaluate("return 'Hello world.'");
            Assert.AreEqual("Hello world.", result);

            result = processor.Evaluate("return 5 - 10 * 3");
            Assert.AreEqual((5 - 10 * 3), result);

            result = processor.Evaluate("return 5 * 3 + 1");
            Assert.AreEqual((5 * 3 + 1), result);
        }
开发者ID:jgabb8989,项目名称:DotQL,代码行数:13,代码来源:LanguageTests.cs

示例2: Calls

        public void Calls()
        {
            var processor = new Processor();

            dynamic result = processor.Evaluate("return { 2 3 4 }->ToList()");
            result = Enumerable.ToList(result);
            Assert.IsTrue(result.Count == 3);
            Assert.AreEqual(result[0], 2);
            Assert.AreEqual(result[1], 3);
            Assert.AreEqual(result[2], 4);

            result = processor.Evaluate("return '1955/3/25'dt->AddMonth(2)");
            Assert.AreEqual(DateTime.Parse("1955/5/25"), result);
        }
开发者ID:jgabb8989,项目名称:DotQL,代码行数:14,代码来源:LanguageTests.cs

示例3: Evaluate

        public void Evaluate()
        {
            var processor = new Processor();

            var result = processor.Evaluate(@"//Nothing but a comment");
            Assert.IsNull(result.Result);
        }
开发者ID:Ancestry,项目名称:DotQL,代码行数:7,代码来源:ProcessorTests.cs

示例4: EmptyModuleDeclaration

        public void EmptyModuleDeclaration()
        {
            var processor = new Processor();
            processor.Execute("module TestModule 1.0.0 { }");

            dynamic result = processor.Evaluate("return Modules");
            Assert.AreEqual(2, result.Count);
        }
开发者ID:jgabb8989,项目名称:DotQL,代码行数:8,代码来源:LanguageTests.cs

示例5: EmptyScript

        public void EmptyScript()
        {
            var processor = new Processor();

            processor.Execute("//Nothing but a comment");
            var result = processor.Evaluate("//Nothing but a comment");
            Assert.IsNull(result);
        }
开发者ID:jgabb8989,项目名称:DotQL,代码行数:8,代码来源:LanguageTests.cs

示例6: EvaluateWithArguments

        public void EvaluateWithArguments()
        {
            var processor = new Processor();

            var result = processor.Evaluate("var x := 5 return x", new Dictionary<string, object> { { "x", 10} });
            Assert.IsTrue(result.Type is Type.BaseIntegerType);
            Assert.AreEqual(10, result.Result);
        }
开发者ID:Ancestry,项目名称:DotQL,代码行数:8,代码来源:ProcessorTests.cs

示例7: DereferenceOnIndex

 public void DereferenceOnIndex()
 {
     var processor = new Processor();
     dynamic result = processor.Evaluate("return { 10 20 30 40 }.(value + index)");
     result = Enumerable.ToList(result);
     Assert.AreEqual(4, result.Count);
     Assert.AreEqual(10, result[0]);
     Assert.AreEqual(43, result[3]);
 }
开发者ID:jgabb8989,项目名称:DotQL,代码行数:9,代码来源:LanguageTests.cs

示例8: DereferenceProducingTuple

 public void DereferenceProducingTuple()
 {
     var processor = new Processor();
     dynamic result = processor.Evaluate("return { 10 20 30 40 }.{ v:value i:index }");
     result = Enumerable.ToList(result);
     Assert.AreEqual(4, result.Count);
     Assert.AreEqual(10, result[0].v);
     Assert.AreEqual(0, result[0].i);
     Assert.AreEqual(40, result[3].v);
     Assert.AreEqual(3, result[3].i);
 }
开发者ID:jgabb8989,项目名称:DotQL,代码行数:11,代码来源:LanguageTests.cs

示例9: Execute

        private static void Execute(StringBuilder sb)
        {
            Console.WriteLine();
            Console.WriteLine("Executing:");
            Console.WriteLine("\"{0}\"", sb.ToString());
            Console.WriteLine();

            try
            {

                var connection = new Processor();

                var result = connection.Evaluate(sb.ToString());
                Console.WriteLine("Results: {0}", result.ToString());
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
            finally
            {
                sb.Clear();
            }
        }
开发者ID:Ancestry,项目名称:DotQL,代码行数:24,代码来源:Program.cs

示例10: SetDereference

 public void SetDereference()
 {
     var processor = new Processor();
     dynamic result = processor.Evaluate("return { 2 3 4 }.(value * 5)");
     result = Enumerable.ToList(result);
     Assert.AreEqual(3, result.Count);
     Assert.AreEqual(10, result[0]);
     Assert.AreEqual(20, result[2]);
 }
开发者ID:jgabb8989,项目名称:DotQL,代码行数:9,代码来源:LanguageTests.cs

示例11: SetAndTupleDereference

 public void SetAndTupleDereference()
 {
     var processor = new Processor();
     dynamic result = processor.Evaluate("return { { x:2 y:'blah' } { x:3 y:'blah2' } { x:4 y:'blah3' } }.(value.x * 5)");
     result = Enumerable.ToList(result);
     Assert.AreEqual(3, result.Count);
     Assert.AreEqual(10, result[0]);
     Assert.AreEqual(20, result[2]);
 }
开发者ID:jgabb8989,项目名称:DotQL,代码行数:9,代码来源:LanguageTests.cs

示例12: SimpleModuleConst

        public void SimpleModuleConst()
        {
            var processor = new Processor();
            processor.Execute("module TestModule 1.0.0 { MyConst: const 5 }");

            dynamic result = processor.Evaluate("using TestModule 1.0.0 return MyConst");
            Assert.AreEqual(5, result);
        }
开发者ID:jgabb8989,项目名称:DotQL,代码行数:8,代码来源:LanguageTests.cs

示例13: SetSelector

        public void SetSelector()
        {
            var processor = new Processor();

            dynamic result = processor.Evaluate("return { 2 3 4 }");
            Assert.IsTrue(result.Count == 3);
            result = Enumerable.ToList(result);
            Assert.AreEqual(result[0], 2);
            Assert.AreEqual(result[1], 3);
            Assert.AreEqual(result[2], 4);

            result = processor.Evaluate("return { 'a' 'b' 'c' }");
            Assert.IsTrue(result.Count == 3);
            result = Enumerable.ToList(result);
            Assert.AreEqual(result[0], "a");
            Assert.AreEqual(result[1], "b");
            Assert.AreEqual(result[2], "c");

            result = processor.Evaluate("return { { x:1 } { x:2 } { x:3 } }");
            Assert.IsTrue(result.Count == 3);
            result = Enumerable.ToList(result);
            Assert.AreEqual(result[0].x, 1);
            Assert.AreEqual(result[1].x, 2);
            Assert.AreEqual(result[2].x, 3);

            result = processor.Evaluate("return { { x:1 y:'a' key{ x } } { x:1 y:'b' key{ x } } }");
            Assert.IsTrue(result.Count == 1);
            result = Enumerable.ToList(result);
            Assert.AreEqual(result[0].x, 1);
        }
开发者ID:jgabb8989,项目名称:DotQL,代码行数:30,代码来源:LanguageTests.cs

示例14: RestrictOnIndex

 public void RestrictOnIndex()
 {
     var processor = new Processor();
     dynamic result = processor.Evaluate("return { 10 20 30 40 }?(index >= 2)");
     result = Enumerable.ToList(result);
     Assert.AreEqual(2, result.Count);
     Assert.AreEqual(30, result[0]);
     Assert.AreEqual(40, result[1]);
 }
开发者ID:jgabb8989,项目名称:DotQL,代码行数:9,代码来源:LanguageTests.cs

示例15: SimpleModuleEnum

        public void SimpleModuleEnum()
        {
            var processor = new Processor();
            processor.Execute("module TestModule 1.0.0 { MyEnum: enum { Red Green } }");

            dynamic result = processor.Evaluate("using TestModule 1.0.0 return Green");
            Assert.AreEqual("Green", result.ToString());
        }
开发者ID:jgabb8989,项目名称:DotQL,代码行数:8,代码来源:LanguageTests.cs


注:本文中的Processor.Evaluate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。