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


C# Runners.GraphSyncData类代码示例

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


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

示例1: SimulateConnectedCBNExecution

        public void SimulateConnectedCBNExecution()
        {
            // Simulate 2 CBNs where one is connected to the other
            // [a = 1]----->[x = a]
            List<string> codes = new List<string>() 
            {
                @"a = 10;", // CBN 1 contents
                @"x = a;"   // CBN 2 contents
            };

            // Simulate 2 CBNs
            Guid cbnGuid1 = System.Guid.NewGuid(); 
            Guid cbnGuid2 = System.Guid.NewGuid(); 
            List<Subtree> added = new List<Subtree>();
            added.Add(ProtoTestFx.TD.TestFrameWork.CreateSubTreeFromCode(cbnGuid1, codes[0]));
            added.Add(ProtoTestFx.TD.TestFrameWork.CreateSubTreeFromCode(cbnGuid2, codes[1]));
            var syncData = new GraphSyncData(null, added, null);

            // Sending the CBN node data to the VM
            // Execute the DS code
            liveRunner.UpdateGraph(syncData);

            // Verify the values of the variables in the CBNs
            AssertValue("a", 10);
            AssertValue("x", 10);
        }
开发者ID:norbertzsiros,项目名称:Dynamo,代码行数:26,代码来源:MicroFeatureTests.cs

示例2: Initialize

        /// <summary>
        /// This method is called by code that intends to start a graph update.
        /// This method is called on the main thread where node collection in a 
        /// WorkspaceModel can be safely accessed.
        /// </summary>
        /// <param name="controller">Reference to an instance of EngineController 
        /// to assist in generating GraphSyncData object for the given set of nodes.
        /// </param>
        /// <param name="workspace">Reference to the WorkspaceModel from which a 
        /// set of updated nodes is computed. The EngineController generates the 
        /// resulting GraphSyncData from this list of updated nodes.</param>
        /// <returns>Returns true if there is any GraphSyncData, or false otherwise
        /// (in which case there will be no need to schedule UpdateGraphAsyncTask 
        /// for execution).</returns>
        /// 
        internal bool Initialize(EngineController controller, WorkspaceModel workspace)
        {
            try
            {
                engineController = controller;
                TargetedWorkspace = workspace;

                ModifiedNodes = ComputeModifiedNodes(workspace);
                graphSyncData = engineController.ComputeSyncData(workspace.Nodes, ModifiedNodes, verboseLogging);
                if (graphSyncData == null)
                    return false;

                // We clear dirty flags before executing the task. If we clear
                // flags after the execution of task, for example in
                // AsyncTask.Completed or in HandleTaskCompletionCore(), as both
                // are executed in the other thread, although some nodes are
                // modified and we request graph execution, but just before
                // computing sync data, the task completion handler jumps in
                // and clear dirty flags. Now graph sync data will be null and
                // graph is in wrong state.
                foreach (var nodeGuid in graphSyncData.NodeIDs)
                {
                    var node = workspace.Nodes.FirstOrDefault(n => n.GUID.Equals(nodeGuid));
                    if (node != null)
                        node.ClearDirtyFlag();
                }

                return true;
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("UpgradeGraphAsyncTask saw: " + e.ToString());
                return false;
            }
        }
开发者ID:DynamoDS,项目名称:Dynamo,代码行数:50,代码来源:UpdateGraphAsyncTask.cs

示例3: TestInstructionStreamMemory_SimpleWorkflow01

        public void TestInstructionStreamMemory_SimpleWorkflow01()
        {
            List<string> codes = new List<string>() 
            {
                "a = 1;",  
                "a = 2;"      
            };

            Guid guid = System.Guid.NewGuid();

            // First run
            // a = 1
            List<Subtree> added = new List<Subtree>();
            Subtree st = ProtoTestFx.TD.TestFrameWork.CreateSubTreeFromCode(guid, codes[0]);
            added.Add(st);
            var syncData = new GraphSyncData(null, added, null);
            liverunner.UpdateGraph(syncData);

            ProtoCore.Mirror.RuntimeMirror mirror = liverunner.InspectNodeValue("a");
            Assert.IsTrue((Int64)mirror.GetData().Data == 1);

            // Modify 
            // a = 2
            List<Subtree> modified = new List<Subtree>(); 
            st = ProtoTestFx.TD.TestFrameWork.CreateSubTreeFromCode(guid, codes[1]);
            modified.Add(st);
            syncData = new GraphSyncData(null, null, modified);
            liverunner.UpdateGraph(syncData);

            mirror = liverunner.InspectNodeValue("a");
            Assert.IsTrue((Int64)mirror.GetData().Data == 2);

            Assert.AreEqual(instrStreamStart, instrStreamEnd);
        }
开发者ID:sh4nnongoh,项目名称:Dynamo,代码行数:34,代码来源:MemoryConsumptionTests.cs

示例4: UpdateGraph

        /// <summary>
        /// Update graph with graph sync data.
        /// </summary>
        /// <param name="graphData"></param>
        /// <param name="verboseLogging"></param>
        public void UpdateGraph(GraphSyncData graphData, bool verboseLogging)
        {
            if (verboseLogging)
                Log("LRS.UpdateGraph: " + graphData);

            liveRunner.UpdateGraph(graphData);
        }
开发者ID:ankushraizada,项目名称:Dynamo,代码行数:12,代码来源:LiveRunnerServices.cs

示例5: UpdateGraph

        /// <summary>
        /// Update graph with graph sync data.
        /// </summary>
        /// <param name="graphData"></param>
        public void UpdateGraph(GraphSyncData graphData)
        {
            if (dynamoModel.DebugSettings.VerboseLogging)
                dynamoModel.Logger.Log("LRS.UpdateGraph: " + graphData);

            liveRunner.UpdateGraph(graphData);
        }
开发者ID:whztt07,项目名称:Dynamo,代码行数:11,代码来源:LiveRunnerServices.cs

示例6: TestAddedNodes01

        public void TestAddedNodes01()
        {
            List<string> codes = new List<string>() 
            {
                "a = 1;"
            };

            Guid guid = System.Guid.NewGuid();
            List<Subtree> added = new List<Subtree>();
            added.Add(CreateSubTreeFromCode(guid, codes[0]));

            var syncData = new GraphSyncData(null, added, null);
         
            // Get astlist from ChangeSetComputer
            ChangeSetComputer changeSetState = new ProtoScript.Runners.ChangeSetComputer(core);
            List<AssociativeNode> astList = changeSetState.GetDeltaASTList(syncData);

            // Get expected ASTList
            // The list must be in the order that it is expected
            List<string> expectedCode = new List<string>() 
            {
                "a = 1;"
            };
            List<AssociativeNode> expectedAstList = ProtoCore.Utils.CoreUtils.BuildASTList(core, expectedCode);

            // Compare ASTs to be equal
            for (int n = 0; n < astList.Count; ++n)
            {
                AssociativeNode node1 = astList[n];
                AssociativeNode node2 = expectedAstList[n];
                bool isEqual = node1.Equals(node2);
                Assert.IsTrue(isEqual);
            }
        }
开发者ID:RobertiF,项目名称:Dynamo,代码行数:34,代码来源:ChangeSetComputerTests.cs

示例7: TestGuidStability

            public void TestGuidStability()
            {

                //Test to ensure that the first time the code is executed the wasTraced attribute is marked as false
                //and the secodn time it is marked as true


                string setupCode =
                @"import(""FFITarget.dll""); 
x = 0; 
mtcA = IncrementerTracedClass.IncrementerTracedClass(x); 
mtcAID = mtcA.ID;
mtcAWasTraced = mtcA.WasCreatedWithTrace(); ";



                // Create 2 CBNs

                List<Subtree> added = new List<Subtree>();


                // Simulate a new new CBN
                Guid guid1 = System.Guid.NewGuid();
                added.Add(ProtoTestFx.TD.TestFrameWork.CreateSubTreeFromCode(guid1, setupCode));

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

                TestFrameWork.AssertValue("mtcAID", 0, astLiveRunner);
                TestFrameWork.AssertValue("mtcAWasTraced", false, astLiveRunner);


                var core = astLiveRunner.RuntimeCore;
                var ctorCallsites = core.RuntimeData.CallsiteCache.Values.Where(c => c.MethodName == "IncrementerTracedClass");

                Assert.IsTrue(ctorCallsites.Count() == 1);
                Guid guid = ctorCallsites.First().CallSiteID;
          


                ExecuteMoreCode("x = 1;");

                // Verify that a is re-executed
                TestFrameWork.AssertValue("mtcAID", 0, astLiveRunner);
                TestFrameWork.AssertValue("mtcAWasTraced", true, astLiveRunner);

                //Verify that the GUID has been adjusted
                var ctorCallsites2 = core.RuntimeData.CallsiteCache.Values.Where(c => c.MethodName == "IncrementerTracedClass");

                Assert.IsTrue(ctorCallsites2.Count() == 1);
                Guid guid2 = ctorCallsites2.First().CallSiteID;

                Assert.AreEqual(guid, guid2);
            }
开发者ID:ankushraizada,项目名称:Dynamo,代码行数:54,代码来源:CallsiteRegen.cs

示例8: GraphUpdateReadyEventArgs

        public GraphUpdateReadyEventArgs(GraphSyncData syncData, EventStatus resultStatus, String errorString)
        {
            this.SyncData = syncData;
            this.ResultStatus = resultStatus;
            this.ErrorString = errorString;

            if (string.IsNullOrEmpty(this.ErrorString))
                this.ErrorString = "";

            Errors = new List<ErrorObject>();
            Warnings = new List<ErrorObject>();
        }
开发者ID:RobertiF,项目名称:Dynamo,代码行数:12,代码来源:LiveRunnerEventArgs.cs

示例9: Initialize

        /// <summary>
        /// Call this method to intialize a CompileCustomNodeAsyncTask with an 
        /// EngineController, nodes from the corresponding CustomNodeWorkspaceModel,
        /// and inputs/outputs of the CustomNodeDefinition.
        /// </summary>
        /// <param name="initParams">Input parameters required for compilation of 
        /// the CustomNodeDefinition.</param>
        /// <returns>Returns true if GraphSyncData is generated successfully and 
        /// that the CompileCustomNodeAsyncTask should be scheduled for execution.
        /// Returns false otherwise.</returns>
        /// 
        internal bool Initialize(CompileCustomNodeParams initParams)
        {
            engineController = initParams.EngineController;

            try
            {
                graphSyncData = engineController.ComputeSyncData(initParams);
                return graphSyncData != null;
            }
            catch (Exception)
            {
                return false;
            }
        }
开发者ID:RobertiF,项目名称:Dynamo,代码行数:25,代码来源:CompileCustomNodeAsyncTask.cs

示例10: Initialize

        /// <summary>
        /// This method is called by codes that intent to start a graph update.
        /// This method is called on the main thread where node collection in a 
        /// WorkspaceModel can be safely accessed.
        /// </summary>
        /// <param name="controller">Reference to an instance of EngineController 
        /// to assist in generating GraphSyncData object for the given set of nodes.
        /// </param>
        /// <param name="workspace">Reference to the WorkspaceModel from which a 
        /// set of updated nodes is computed. The EngineController generates the 
        /// resulting GraphSyncData from this list of updated nodes.</param>
        /// <returns>Returns true if there is any GraphSyncData, or false otherwise
        /// (in which case there will be no need to schedule UpdateGraphAsyncTask 
        /// for execution).</returns>
        /// 
        internal bool Initialize(EngineController controller, WorkspaceModel workspace)
        {
            try
            {
                engineController = controller;
                TargetedWorkspace = workspace;

                modifiedNodes = ComputeModifiedNodes(workspace);
                graphSyncData = engineController.ComputeSyncData(modifiedNodes);
                return graphSyncData != null;
            }
            catch (Exception)
            {
                return false;
            }
        }
开发者ID:whztt07,项目名称:Dynamo,代码行数:31,代码来源:UpdateGraphAsyncTask.cs

示例11: TestPreviewModify1Node01

        public void TestPreviewModify1Node01()
        {
            List<string> codes = new List<string>() 
            {
               @"
                    a = 1;
                ",
                 
               @"
                    x = a;
                    y = x;
                ",

               @"
                    a = 10;
                ",
            };

            Guid guid1 = System.Guid.NewGuid();
            Guid guid2 = System.Guid.NewGuid();

            // Create and run the graph  [a = 1;] and [x = a; y = x;]
            ProtoScript.Runners.LiveRunner liveRunner = new ProtoScript.Runners.LiveRunner();
            List<Subtree> added = new List<Subtree>();
            added.Add(CreateSubTreeFromCode(guid1, codes[0]));
            added.Add(CreateSubTreeFromCode(guid2, codes[1]));
            var syncData = new GraphSyncData(null, added, null);
            liveRunner.UpdateGraph(syncData);


            // Modify [a = 1;] to [a = 10;] 
            List<Subtree> modified = new List<Subtree>();
            modified.Add(CreateSubTreeFromCode(guid1, codes[2]));
            syncData = new GraphSyncData(null, null, modified);

            // Get astlist from ChangeSetComputer
            ChangeSetComputer changeSetState = new ProtoScript.Runners.ChangeSetComputer(liveRunner.Core);
            List<AssociativeNode> astList = changeSetState.GetDeltaASTList(syncData);

            // Get the the preview guids (affected graphs)
            List<Guid> reachableGuidList = changeSetState.EstimateNodesAffectedByASTList(astList);

            // Check if the the affected guids are in the list
            List<Guid> expectedGuid = new List<Guid>{guid2};
            AssertPreview(reachableGuidList, expectedGuid, 1);
        }
开发者ID:whztt07,项目名称:Dynamo,代码行数:46,代码来源:PreviewChangeSetTests.cs

示例12: Initialize

        /// <summary>
        /// This method is called by code that intends to start a graph update.
        /// This method is called on the main thread where node collection in a 
        /// WorkspaceModel can be safely accessed.
        /// </summary>
        /// <param name="controller">Reference to an instance of EngineController 
        /// to assist in generating GraphSyncData object for the given set of nodes.
        /// </param>
        /// <param name="workspace">Reference to the WorkspaceModel from which a 
        /// set of updated nodes is computed. The EngineController generates the 
        /// resulting GraphSyncData from this list of updated nodes.</param>
        /// <returns>Returns true if there is any GraphSyncData, or false otherwise
        /// (in which case there will be no need to schedule UpdateGraphAsyncTask 
        /// for execution).</returns>
        /// 
        internal bool Initialize(EngineController controller, WorkspaceModel workspace)
        {
            try
            {
                engineController = controller;
                TargetedWorkspace = workspace;

                ModifiedNodes = ComputeModifiedNodes(workspace);
                graphSyncData = engineController.ComputeSyncData(workspace.Nodes, ModifiedNodes, verboseLogging);
                return graphSyncData != null;
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("UpgradeGraphAsyncTask saw: " + e.ToString());
                return false;
            }
        }
开发者ID:rafatahmed,项目名称:Dynamo,代码行数:32,代码来源:UpdateGraphAsyncTask.cs

示例13: SimulateCBNExecution

        public void SimulateCBNExecution()
        {
            // DS code in a CBN node
            string code = @"a = 10;";
            
            // Generate a GUID for the CBN
            Guid guid = System.Guid.NewGuid();

            // Build data structure that contains the DS code in the CBN
            // This simulates Dynamo generating the CBN node data
            List<Subtree> added = new List<Subtree>();
            added.Add(ProtoTestFx.TD.TestFrameWork.CreateSubTreeFromCode(guid, code));
            var syncData = new GraphSyncData(null, added, null);

            // Sending the CBN node data to the VM
            // Execute the DS code
            liveRunner.UpdateGraph(syncData);

            // Verify the CBN result
            AssertValue("a", 10);
        }
开发者ID:norbertzsiros,项目名称:Dynamo,代码行数:21,代码来源:MicroFeatureTests.cs

示例14: Initialize

        /// <summary>
        /// Call this method to intialize a CompileCustomNodeAsyncTask with an 
        /// EngineController and an GraphSyncData that is required to compile the 
        /// associated custom node.
        /// </summary>
        /// <param name="initParams">Input parameters required for custom node 
        /// graph updates.</param>
        /// <returns>Returns true if GraphSyncData is not empty and that the 
        /// CompileCustomNodeAsyncTask should be scheduled for execution. Returns
        /// false otherwise.</returns>
        /// 
        internal bool Initialize(CompileCustomNodeParams initParams)
        {
            if (initParams == null)
                throw new ArgumentNullException("initParams");

            engineController = initParams.EngineController;
            graphSyncData = initParams.SyncData;

            if (engineController == null)
                throw new ArgumentNullException("engineController");
            if (graphSyncData == null)
                throw new ArgumentNullException("graphSyncData");

            var added = graphSyncData.AddedSubtrees;
            var deleted = graphSyncData.DeletedSubtrees;
            var modified = graphSyncData.ModifiedSubtrees;

            // Returns true if there is any actual data.
            return ((added != null && added.Count > 0) ||
                    (modified != null && modified.Count > 0) ||
                    (deleted != null && deleted.Count > 0));
        }
开发者ID:norbertzsiros,项目名称:Dynamo,代码行数:33,代码来源:CompileCustomNodeAsyncTask.cs

示例15: GraphILTest_Assign01

        public void GraphILTest_Assign01()
        {
            // Build the AST trees
            ProtoCore.AST.AssociativeAST.BinaryExpressionNode assign = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
                new ProtoCore.AST.AssociativeAST.IdentifierNode("a"),
                new ProtoCore.AST.AssociativeAST.IntNode(10),
                ProtoCore.DSASM.Operator.assign);
            List<ProtoCore.AST.AssociativeAST.AssociativeNode> astList = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
            astList.Add(assign);

            // 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
            ProtoScript.Runners.ILiveRunner liveRunner = new ProtoScript.Runners.LiveRunner();
            liveRunner.UpdateGraph(syncData);

            ProtoCore.Mirror.RuntimeMirror mirror = liveRunner.InspectNodeValue("a");
            Assert.IsTrue((Int64)mirror.GetData().Data == 10);
        }
开发者ID:algobasket,项目名称:Dynamo,代码行数:22,代码来源:MicroFeatureTests.cs


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