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


C# LiveRunner.ResetVMAndResyncGraph方法代码示例

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


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

示例1: Setup

 public override void Setup()
 {
     base.Setup();
     liveRunner = new ProtoScript.Runners.LiveRunner();
     liveRunner.ResetVMAndResyncGraph(new List<string> { "FFITarget.dll" });
     runtimeCore = liveRunner.RuntimeCore;
 }
开发者ID:norbertzsiros,项目名称:Dynamo,代码行数:7,代码来源:MicroFeatureTests.cs

示例2: TestAdd01

        public void TestAdd01()
        {
            List<string> codes = new List<string>() 
            {
                "a = 1;",
                "x = a; y = a; z = a; p = DummyPoint.ByCoordinates(x, y, z); px = p.X;",
            };
            List<Guid> guids = Enumerable.Range(0, codes.Count).Select(_ => System.Guid.NewGuid()).ToList();
            IEnumerable<int> index = Enumerable.Range(0, codes.Count);

            int shuffleCount = codes.Count;

            // in which add order, LiveRunner should get the same result.
            for (int i = 0; i < shuffleCount; ++i)
            {
                ILiveRunner liveRunner = new ProtoScript.Runners.LiveRunner();
                liveRunner.ResetVMAndResyncGraph(new List<string> { "FFITarget.dll" });

                index = index.OrderBy(_ => randomGen.Next());
                var added = index.Select(idx => ProtoTestFx.TD.TestFrameWork.CreateSubTreeFromCode(guids[idx], codes[idx])).ToList();

                var syncData = new GraphSyncData(null, added, null);
                liveRunner.UpdateGraph(syncData);

                ProtoCore.Mirror.RuntimeMirror mirror = liveRunner.InspectNodeValue("px");
                var value = (double)mirror.GetData().Data;
                Assert.AreEqual(value, 1);
            }
        }
开发者ID:norbertzsiros,项目名称:Dynamo,代码行数:29,代码来源:MicroFeatureTests.cs

示例3: TestFunctionObjectInApply

        public void TestFunctionObjectInApply()
        {
            liveRunner = new ProtoScript.Runners.LiveRunner();
            liveRunner.ResetVMAndResyncGraph(new List<string> { "FunctionObject.ds" });
            string code = @"
 def foo(x,y ) { return = x + y; }
 f = _SingleFunctionObject(foo, 2, {1}, {null, 42}, true); r = __Apply(f, 3);
 ";

            Guid guid = System.Guid.NewGuid();
            List<Subtree> added = new List<Subtree>();
            {
                added.Add(ProtoTestFx.TD.TestFrameWork.CreateSubTreeFromCode(guid, code));
                var syncData = new GraphSyncData(null, added, null);
                liveRunner.UpdateGraph(syncData);
                AssertValue("r", 45);
            }
        }
开发者ID:norbertzsiros,项目名称:Dynamo,代码行数:18,代码来源:MicroFeatureTests.cs

示例4: GraphILTest_FFIClassUsage_03

        public void GraphILTest_FFIClassUsage_03()
        {
            //
            //  a=2;
            //  tSSA_150=1..10;
            //  x= tSSA_150;
            //  tSSA_151=x;
            //  tSSA_152=a;
            //  tSSA_153=( tSSA_151+ tSSA_152);
            //  var_79153f69593b4fde9bb50646a1aaea96= tSSA_153;
            //  tSSA_154=Point.ByCoordinates(var_79153f69593b4fde9bb50646a1aaea96,a,a);
            //  var_347c1113204a4d15a22f7daf83bbe20e= tSSA_154;
            //

            //
            //  a=2;
            //  x=1..10;
            //  var_79153f69593b4fde9bb50646a1aaea96=(x+a);
            //  var_347c1113204a4d15a22f7daf83bbe20e=Point.ByCoordinates(var_79153f69593b4fde9bb50646a1aaea96,a,a);
            //

            ProtoScript.Runners.ILiveRunner liveRunner = new ProtoScript.Runners.LiveRunner();

            List<ProtoCore.AST.AssociativeAST.AssociativeNode> astList = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
            //==============================================
            // Build the import Nodes
            //==============================================
            //ProtoCore.AST.AssociativeAST.ImportNode importNode = new ProtoCore.AST.AssociativeAST.ImportNode();
            //importNode.ModuleName = "ProtoGeometry.dll";
            //astList.Add(importNode);

            List<string> libs = new List<string>();
            libs.Add("ProtoGeometry.dll");
            liveRunner.ResetVMAndResyncGraph(libs);




            // Build the AST trees
            // a = 2
            ProtoCore.AST.AssociativeAST.BinaryExpressionNode assign1 = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
                new ProtoCore.AST.AssociativeAST.IdentifierNode("a"),
                new ProtoCore.AST.AssociativeAST.IntNode(2),
                ProtoCore.DSASM.Operator.assign);
            astList.Add(assign1);


            // x = 1..10;
            ProtoCore.AST.AssociativeAST.RangeExprNode rangeExpr = new ProtoCore.AST.AssociativeAST.RangeExprNode();
            rangeExpr.FromNode = new ProtoCore.AST.AssociativeAST.IntNode(1);
            rangeExpr.ToNode = new ProtoCore.AST.AssociativeAST.IntNode(10);
            rangeExpr.StepNode = new ProtoCore.AST.AssociativeAST.IntNode(1);
            ProtoCore.AST.AssociativeAST.BinaryExpressionNode assign2 = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
                new ProtoCore.AST.AssociativeAST.IdentifierNode("x"),
                rangeExpr,
                ProtoCore.DSASM.Operator.assign);
            astList.Add(assign2);

            // var_79153f69593b4fde9bb50646a1aaea96 = (x + a);
            ProtoCore.AST.AssociativeAST.BinaryExpressionNode assign3 = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
                new ProtoCore.AST.AssociativeAST.IdentifierNode("dude"),
                new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
                    new ProtoCore.AST.AssociativeAST.IdentifierNode("x"),
                    new ProtoCore.AST.AssociativeAST.IdentifierNode("a"),
                    ProtoCore.DSASM.Operator.add),
                ProtoCore.DSASM.Operator.assign);

            astList.Add(assign3);




            //==============================================
            // Build the constructor call nodes
            // Point.ByCoordinates(10,10,10)
            //==============================================
            ProtoCore.AST.AssociativeAST.FunctionCallNode constructorCall = new ProtoCore.AST.AssociativeAST.FunctionCallNode();
            constructorCall.Function = new ProtoCore.AST.AssociativeAST.IdentifierNode("ByCoordinates");
            List<ProtoCore.AST.AssociativeAST.AssociativeNode> listArgs = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
            listArgs.Add(new ProtoCore.AST.AssociativeAST.IdentifierNode("dude"));
            listArgs.Add(new ProtoCore.AST.AssociativeAST.IdentifierNode("a"));
            listArgs.Add(new ProtoCore.AST.AssociativeAST.IdentifierNode("a"));
            constructorCall.FormalArguments = listArgs;

            string className = "Point";
            ProtoCore.AST.AssociativeAST.IdentifierNode inode = new ProtoCore.AST.AssociativeAST.IdentifierNode(className);

            ProtoCore.AST.AssociativeAST.FunctionDotCallNode dotCall = ProtoCore.Utils.CoreUtils.GenerateCallDotNode(inode, constructorCall, liveRunner.Core);

            //==============================================
            // Build the binary expression 
            // p = Point.ByCoordinates(10,10,10)
            //==============================================
            ProtoCore.AST.AssociativeAST.BinaryExpressionNode stmt1 = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
                new ProtoCore.AST.AssociativeAST.IdentifierNode("final"),
                dotCall,
                ProtoCore.DSASM.Operator.assign);
            astList.Add(stmt1);


//.........这里部分代码省略.........
开发者ID:algobasket,项目名称:Dynamo,代码行数:101,代码来源:MicroFeatureTests.cs

示例5: GraphILTest_FFIClassUsage_02

        public void GraphILTest_FFIClassUsage_02()
        {
            ProtoScript.Runners.ILiveRunner liveRunner = new ProtoScript.Runners.LiveRunner();

            List<ProtoCore.AST.AssociativeAST.AssociativeNode> astList = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
            //==============================================
            // Build the import Nodes
            //==============================================
            List<string> libs = new List<string>();
            libs.Add("ProtoGeometry.dll");
            liveRunner.ResetVMAndResyncGraph(libs);

            //==============================================
            // Build the constructor call nodes
            // Point.ByCoordinates(10,10,10)
            //==============================================
            ProtoCore.AST.AssociativeAST.FunctionCallNode constructorCall = new ProtoCore.AST.AssociativeAST.FunctionCallNode();
            constructorCall.Function = new ProtoCore.AST.AssociativeAST.IdentifierNode("ByCoordinates");
            List<ProtoCore.AST.AssociativeAST.AssociativeNode> listArgs = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
            listArgs.Add(new ProtoCore.AST.AssociativeAST.DoubleNode(10.0));
            listArgs.Add(new ProtoCore.AST.AssociativeAST.DoubleNode(10.0));
            listArgs.Add(new ProtoCore.AST.AssociativeAST.DoubleNode(10.0));
            constructorCall.FormalArguments = listArgs;

            string className = "Point";
            ProtoCore.AST.AssociativeAST.IdentifierNode inode = new ProtoCore.AST.AssociativeAST.IdentifierNode(className);

            ProtoCore.AST.AssociativeAST.FunctionDotCallNode dotCall = ProtoCore.Utils.CoreUtils.GenerateCallDotNode(inode, constructorCall, liveRunner.Core);

            //==============================================
            // Build the binary expression 
            // p = Point.ByCoordinates(10,10,10)
            //==============================================
            ProtoCore.AST.AssociativeAST.BinaryExpressionNode stmt1 = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
                new ProtoCore.AST.AssociativeAST.IdentifierNode("p"),
                dotCall,
                ProtoCore.DSASM.Operator.assign);
            astList.Add(stmt1);
            //==============================================
            // Translate the point
            // newPoint = p.Translate(1,2,3);
            //==============================================
            ProtoCore.AST.AssociativeAST.FunctionCallNode functionCallTranslate = new ProtoCore.AST.AssociativeAST.FunctionCallNode();
            functionCallTranslate.Function = new ProtoCore.AST.AssociativeAST.IdentifierNode("Translate");
            listArgs = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
            listArgs.Add(new ProtoCore.AST.AssociativeAST.DoubleNode(1.0));
            listArgs.Add(new ProtoCore.AST.AssociativeAST.DoubleNode(2.0));
            listArgs.Add(new ProtoCore.AST.AssociativeAST.DoubleNode(3.0));
            functionCallTranslate.FormalArguments = listArgs;

            //ProtoCore.AST.AssociativeAST.FunctionDotCallNode dotCallTranslate = new ProtoCore.AST.AssociativeAST.FunctionDotCallNode("p", functionCallTranslate);
            className = "p";
            inode = new ProtoCore.AST.AssociativeAST.IdentifierNode(className);

            ProtoCore.AST.AssociativeAST.FunctionDotCallNode dotCallTranslate = ProtoCore.Utils.CoreUtils.GenerateCallDotNode(inode, functionCallTranslate, liveRunner.Core);

            //==============================================
            // Build the binary expression 
            //==============================================
            ProtoCore.AST.AssociativeAST.BinaryExpressionNode stmt2 = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
                new ProtoCore.AST.AssociativeAST.IdentifierNode("newPoint"),
                dotCallTranslate,
                ProtoCore.DSASM.Operator.assign);
            astList.Add(stmt2);

            //==============================================
            // Build a binary expression to retirieve the x property
            // xval = newPoint.X
            //==============================================
            ProtoCore.AST.AssociativeAST.IdentifierListNode identListNode = new ProtoCore.AST.AssociativeAST.IdentifierListNode();
            identListNode.LeftNode = new ProtoCore.AST.AssociativeAST.IdentifierNode("newPoint");
            identListNode.Optr = ProtoCore.DSASM.Operator.dot;
            identListNode.RightNode = new ProtoCore.AST.AssociativeAST.IdentifierNode("X");
            ProtoCore.AST.AssociativeAST.BinaryExpressionNode stmt3 = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
                new ProtoCore.AST.AssociativeAST.IdentifierNode("xval"),
                identListNode,
                ProtoCore.DSASM.Operator.assign);
            astList.Add(stmt3);
            //==============================================
            // emit the DS code from the AST tree
            //
            // import ("ProtoGeometry.dll");
            // p = Point.Bycoordinates(10.0, 10.0, 10.0);
            // newPoint = p.Translate(1.0,2.0,3.0);
            // xval = newPoint.X;
            //
            //==============================================
            // Instantiate GraphSyncData
            List<Subtree> addedList = new List<Subtree>();
            addedList.Add(new Subtree(astList, System.Guid.NewGuid()));
            GraphSyncData syncData = new GraphSyncData(null, addedList, null);

            // emit the DS code from the AST tree
            liveRunner.UpdateGraph(syncData);

            ProtoCore.Mirror.RuntimeMirror mirror = liveRunner.InspectNodeValue("xval");
            Assert.IsTrue((double)mirror.GetData().Data == 11.0);

        }
开发者ID:algobasket,项目名称:Dynamo,代码行数:99,代码来源:MicroFeatureTests.cs

示例6: GraphILTest_FFIClassUsage_04

        public void GraphILTest_FFIClassUsage_04()
        {

            //
            //  a=2;
            //  x=1..10;
            //  var_79153f69593b4fde9bb50646a1aaea96=(x+a);
            //  var_347c1113204a4d15a22f7daf83bbe20e=Point.ByCoordinates(var_79153f69593b4fde9bb50646a1aaea96,a,a);
            //

            ProtoScript.Runners.ILiveRunner liveRunner = new ProtoScript.Runners.LiveRunner();

            //==============================================
            // Build the import Nodes
            //==============================================
            List<string> libs = new List<string>();
            libs.Add("ProtoGeometry.dll");
            liveRunner.ResetVMAndResyncGraph(libs);

            string code = null;
            ProtoCore.AST.Node codeBlockNode = null;
            ProtoCore.AST.AssociativeAST.CodeBlockNode commentNode = null;
            List<ProtoCore.AST.Node> nodes = new List<ProtoCore.AST.Node>();
            List<ProtoCore.AST.AssociativeAST.AssociativeNode> astList = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();

            code = null;
            nodes = new List<ProtoCore.AST.Node>();
            astList = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
            codeBlockNode = null;

            code = @"
a=2;
x=1..10;
y=(x+a);
z=Point.ByCoordinates(y,a,a);
";
            commentNode = null;
            codeBlockNode = GraphToDSCompiler.GraphUtilities.Parse(code, out commentNode);
            nodes = ProtoCore.Utils.ParserUtils.GetAstNodes(codeBlockNode);

            foreach (ProtoCore.AST.Node node in nodes)
            {
                astList.Add(node as ProtoCore.AST.AssociativeAST.AssociativeNode);
            }


            //==============================================
            // emit the DS code from the AST tree
            //==============================================

            Guid guid = System.Guid.NewGuid();
            // Instantiate GraphSyncData
            List<Subtree> addedList = new List<Subtree>();
            addedList.Add(new Subtree(astList, guid));
            GraphSyncData syncData = new GraphSyncData(null, addedList, null);

            // emit the DS code from the AST tree
            liveRunner.UpdateGraph(syncData);

            const int rep = 2;
            for (int n = 0; n < rep; ++n)
            {

                //////
                code = null;
                nodes = new List<ProtoCore.AST.Node>();
                astList = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
                codeBlockNode = null;

                code = @"
a = null;
a=2;
x = null;
x=1..10;
y = null;
y=(x+a);
z= null;
z=Point.ByCoordinates(y,a,a);
";
                commentNode = null;
                codeBlockNode = GraphToDSCompiler.GraphUtilities.Parse(code, out commentNode);
                nodes = ProtoCore.Utils.ParserUtils.GetAstNodes(codeBlockNode);

                foreach (ProtoCore.AST.Node node in nodes)
                {
                    astList.Add(node as ProtoCore.AST.AssociativeAST.AssociativeNode);
                }


                // Instantiate GraphSyncData
                addedList = new List<Subtree>();
                addedList.Add(new Subtree(astList, guid));
                syncData = new GraphSyncData(null, null, addedList);

                // emit the DS code from the AST tree
                liveRunner.UpdateGraph(syncData);

                ProtoCore.Mirror.RuntimeMirror mirror = liveRunner.InspectNodeValue("z");
                var zValues = mirror.GetData().GetElements();
                Assert.IsTrue(zValues != null && zValues.Count == 10);
//.........这里部分代码省略.........
开发者ID:algobasket,项目名称:Dynamo,代码行数:101,代码来源:MicroFeatureTests.cs


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