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


C# Engine.EngineController类代码示例

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


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

示例1: LoadWorkspaceFromJson

        /// <summary>
        /// Load a WorkspaceModel from json. If the WorkspaceModel is a HomeWorkspaceModel
        /// it will be set as the current workspace.
        /// </summary>
        /// <param name="json"></param>
        public static WorkspaceModel LoadWorkspaceFromJson(string json, LibraryServices libraryServices,
            EngineController engineController, DynamoScheduler scheduler, NodeFactory factory,
            bool isTestMode, bool verboseLogging, CustomNodeManager manager)
        {
            var settings = new JsonSerializerSettings
            {
                Error = (sender, args) =>
                {
                    args.ErrorContext.Handled = true;
                    Console.WriteLine(args.ErrorContext.Error);
                },
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
                TypeNameHandling = TypeNameHandling.Auto,
                Formatting = Formatting.Indented,
                Converters = new List<JsonConverter>{
                        new ConnectorConverter(),
                        new AnnotationConverter(),
                        new WorkspaceConverter(engineController, scheduler, factory, isTestMode, verboseLogging),
                        new NodeModelConverter(manager, libraryServices),
                    },
                ReferenceResolverProvider = () => { return new IdReferenceResolver(); }
            };

            var result = ReplaceTypeDeclarations(json, true);
            var ws = JsonConvert.DeserializeObject<WorkspaceModel>(result, settings);

            return ws;
        }
开发者ID:Conceptual-Design,项目名称:Dynamo,代码行数:33,代码来源:Workspaces.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: WorkspaceComparisonData

            public WorkspaceComparisonData(WorkspaceModel workspace, EngineController controller)
            {
                Guid = workspace.Guid;
                NodeCount = workspace.Nodes.Count();
                ConnectorCount = workspace.Connectors.Count();
                GroupCount = workspace.Annotations.Count();
                NoteCount = workspace.Notes.Count();
                NodeTypeMap = new Dictionary<Guid, Type>();
                NodeDataMap = new Dictionary<Guid, List<object>>();
                InportCountMap = new Dictionary<Guid, int>();
                OutportCountMap = new Dictionary<Guid, int>();

                foreach (var n in workspace.Nodes)
                {
                    NodeTypeMap.Add(n.GUID, n.GetType());

                    var portvalues = new List<object>();
                    foreach (var p in n.OutPorts)
                    {
                        var value = n.GetValue(p.Index, controller);
                        if (value.IsCollection)
                        {
                            portvalues.Add(GetStringRepOfCollection(value));
                        }
                        else
                        {
                            portvalues.Add(value.StringData);
                        }
                    }
                    
                    NodeDataMap.Add(n.GUID, portvalues);
                    InportCountMap.Add(n.GUID, n.InPorts.Count);
                    OutportCountMap.Add(n.GUID, n.OutPorts.Count);
                }
            }
开发者ID:DynamoDS,项目名称:Dynamo,代码行数:35,代码来源:SerializationTests.cs

示例4: QueryMirrorDataAsyncTask

        internal QueryMirrorDataAsyncTask(QueryMirrorDataParams initParams)
            : base(initParams.Scheduler)
        {
            if (initParams.EngineController == null)
                throw new ArgumentNullException("initParams.EngineController");
            if (string.IsNullOrEmpty(initParams.VariableName))
                throw new ArgumentNullException("initParams.VariableName");

            variableName = initParams.VariableName;
            engineController = initParams.EngineController;
        }
开发者ID:ankushraizada,项目名称:Dynamo,代码行数:11,代码来源:QueryMirrorDataAsyncTask.cs

示例5: Initialize

        /// <summary>
        /// This method is called by task creator to associate the trace data with
        /// the current instance of virtual machine. The given WorkspaceModel can
        /// optionally contain saved trace data in a previous execution session. As
        /// a side-effect, this method resets "WorkspaceModel.PreloadedTraceData"
        /// data member to ensure the correctness of the execution flow.
        /// </summary>
        /// <param name="controller">Reference to the EngineController on which the 
        /// loaded trace data should be set.</param>
        /// <param name="workspace">The workspace from which the trace data should 
        /// be retrieved.</param>
        /// <returns>If the given WorkspaceModel contains saved trace data, this 
        /// method returns true, in which case the task needs to be scheduled.
        /// Otherwise, the method returns false.</returns>
        /// 
        internal bool Initialize(EngineController controller, HomeWorkspaceModel workspace)
        {
            if (controller == null || (controller.LiveRunnerCore == null))
                return false;

            engineController = controller;
            traceData = workspace.PreloadedTraceData;

            TargetedWorkspace = workspace;
            workspace.PreloadedTraceData = null;
            return ((traceData != null) && traceData.Any());
        }
开发者ID:norbertzsiros,项目名称:Dynamo,代码行数:27,代码来源:SetTraceDataAsyncTask.cs

示例6: 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 the list of node id's that will be executed in the next run
 /// for execution).</returns>
 internal List<Guid> Initialize(EngineController controller, WorkspaceModel workspace)
 {
     try
     {
         engineController = controller;
         TargetedWorkspace = workspace;                
         modifiedNodes = ComputeModifiedNodes(workspace);                
         previewGraphData = engineController.PreviewGraphSyncData(modifiedNodes,verboseLogging);
         return previewGraphData;
     }
     catch (Exception e)
     {             
         return null;
     }
 }
开发者ID:sh4nnongoh,项目名称:Dynamo,代码行数:28,代码来源:PreviewGraphAsyncTask.cs

示例7: CreateClassHighlightRule

        /// <summary>
        /// Create hight lighting rule for class.
        /// </summary>
        /// <param name="engineController"></param>
        /// <returns></returns>
        public static HighlightingRule CreateClassHighlightRule(EngineController engineController)
        {
            Color color = (Color)ColorConverter.ConvertFromString("#2E998F");
            var classHighlightRule = new HighlightingRule
            {
                Color = new HighlightingColor()
                {
                    Foreground = new CodeHighlightingRuleFactory.CustomizedBrush(color)
                }
            };

            var wordList = engineController.CodeCompletionServices.GetClasses();
            String regex = String.Format(@"\b({0})\b", String.Join("|", wordList));
            classHighlightRule.Regex = new Regex(regex);

            return classHighlightRule;
        }
开发者ID:Conceptual-Design,项目名称:Dynamo,代码行数:22,代码来源:CodeBlockEditorUtils.cs

示例8: CreateMethodHighlightRule

        /// <summary>
        /// Create hight lighting rule for method.
        /// </summary>
        /// <returns></returns>
        public static HighlightingRule CreateMethodHighlightRule(EngineController engineController)
        {
            Color color = (Color)ColorConverter.ConvertFromString("#417693");
            var methodHighlightRule = new HighlightingRule
            {
                Color = new HighlightingColor()
                {
                    Foreground = new CodeHighlightingRuleFactory.CustomizedBrush(color)
                }
            };

            var wordList = engineController.CodeCompletionServices.GetGlobals();
            String regex = String.Format(@"\b({0})({0})?\b", String.Join("|", wordList));
            methodHighlightRule.Regex = new Regex(regex);

            return methodHighlightRule;
        }
开发者ID:ankushraizada,项目名称:Dynamo,代码行数:21,代码来源:CodeBlockEditorUtils.cs

示例9: GeneratedGraphicItems

        public static List<IGraphicItem> GeneratedGraphicItems(this NodeModel node, EngineController engineController)
        {
            var ids = node.GetAllOutportAstIdentifiers();

            var results = new List<IGraphicItem>();

            foreach (var id in ids)
            {
                var mirror = engineController.GetMirror(id);
                if (mirror == null) continue;

                var mirrorData = mirror.GetData();
                if (mirrorData == null) continue;

                GetGraphicItemsFromMirrorData(mirrorData, results);
            }

            return results;
        }
开发者ID:norbertzsiros,项目名称:Dynamo,代码行数:19,代码来源:NodeModelExtensions.cs

示例10: 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

示例11: RunTest

        public override bool RunTest(NodeModel node, EngineController engine, StreamWriter writer)
        {
            bool pass = false;

            var valueMap = new Dictionary<Guid, String>();
            if (node.OutPorts.Count > 0)
            {
                var firstNodeConnectors = node.AllConnectors.ToList(); //Get node connectors
                foreach (ConnectorModel connector in firstNodeConnectors)
                {
                    Guid guid = connector.Start.Owner.GUID;
                    if (!valueMap.ContainsKey(guid))
                    {
                        Object data = connector.Start.Owner.GetValue(0, engine).Data;
                        String val = data != null ? data.ToString() : "null";
                        valueMap.Add(guid, val);
                        writer.WriteLine(guid + " :: " + val);
                        writer.Flush();
                    }
                }
            }

            int numberOfUndosNeeded = Mutate(node);
            Thread.Sleep(100);

            writer.WriteLine("### - Beginning undo");
            for (int iUndo = 0; iUndo < numberOfUndosNeeded; iUndo++)
            {
                DynamoViewModel.UIDispatcher.Invoke(new Action(() =>
                {
                    DynamoModel.UndoRedoCommand undoCommand =
                        new DynamoModel.UndoRedoCommand(DynamoModel.UndoRedoCommand.Operation.Undo);

                    DynamoViewModel.ExecuteCommand(undoCommand);

                }));
                Thread.Sleep(100);
            }
            writer.WriteLine("### - undo complete");
            writer.Flush();

            ExecuteAndWait();

            writer.WriteLine("### - Beginning test of NumberRange");
            if (node.OutPorts.Count > 0)
            {
                try
                {
                    var firstNodeConnectors = node.AllConnectors.ToList();
                    foreach (ConnectorModel connector in firstNodeConnectors)
                    {
                        String valmap = valueMap[connector.Start.Owner.GUID].ToString();
                        Object data = connector.Start.Owner.GetValue(0, engine).Data;
                        String nodeVal = data != null ? data.ToString() : "null";

                        if (valmap != nodeVal)
                        {
                            writer.WriteLine("!!!!!!!!!!! - test of NumberRange is failed");
                            writer.WriteLine(node.GUID);

                            writer.WriteLine("Was: " + nodeVal);
                            writer.WriteLine("Should have been: " + valmap);
                            writer.Flush();
                            return pass;
                        }
                    }
                }
                catch (Exception)
                {
                    writer.WriteLine("!!!!!!!!!!! - test of NumberRange is failed");
                    writer.Flush();
                    return pass;
                }
            }
            writer.WriteLine("### - test of NumberRange complete");
            writer.Flush();

            return pass = true;
        }
开发者ID:nmeek,项目名称:Dynamo,代码行数:79,代码来源:NumberRangeMutator.cs

示例12: HomeWorkspaceModel

 public HomeWorkspaceModel(Guid guid, EngineController engine,
     DynamoScheduler scheduler,
     NodeFactory factory,
     IEnumerable<KeyValuePair<Guid, List<CallSite.RawTraceData>>> traceData,
     IEnumerable<NodeModel> nodes,
     IEnumerable<NoteModel> notes,
     IEnumerable<AnnotationModel> annotations,
     IEnumerable<PresetModel> presets,
     ElementResolver resolver,
     WorkspaceInfo info,
     bool verboseLogging,
     bool isTestMode):this(engine, scheduler, factory, traceData, nodes, notes, 
         annotations, presets, resolver, info, verboseLogging, isTestMode)
 { Guid = guid; }
开发者ID:Conceptual-Design,项目名称:Dynamo,代码行数:14,代码来源:HomeWorkspaceModel.cs

示例13: ResetEngine

        /// <summary>
        /// Call this method to reset the virtual machine, avoiding a race 
        /// condition by using a thread join inside the vm executive.
        /// TODO(Luke): Push this into a resync call with the engine controller
        /// </summary>
        /// <param name="controller"></param>
        /// <param name="markNodesAsDirty">Set this parameter to true to force 
        ///     reset of the execution substrait. Note that setting this parameter 
        ///     to true will have a negative performance impact.</param>
        public void ResetEngine(EngineController controller, bool markNodesAsDirty = false)
        {
            if (EngineController != null)
            {
                EngineController.MessageLogged -= Log;
                EngineController.LibraryServices.LibraryLoaded -= LibraryLoaded;
            }

            EngineController = controller;
            controller.MessageLogged += Log;
            controller.LibraryServices.LibraryLoaded += LibraryLoaded;
            
            if (markNodesAsDirty)
            {
                // Mark all nodes as dirty so that AST for the whole graph will be
                // regenerated.
                MarkNodesAsModifiedAndRequestRun(Nodes); 
            }

            if (RunSettings.RunType == RunType.Automatic)
                Run();
        }
开发者ID:joespiff,项目名称:Dynamo,代码行数:31,代码来源:HomeWorkspaceModel.cs

示例14: HomeWorkspaceModel

        public HomeWorkspaceModel(
            EngineController engine, 
            DynamoScheduler scheduler, 
            NodeFactory factory,
            IEnumerable<KeyValuePair<Guid, List<string>>> traceData, 
            IEnumerable<NodeModel> e, 
            IEnumerable<NoteModel> n, 
            IEnumerable<AnnotationModel> a,
            IEnumerable<PresetModel> presets,
            ElementResolver resolver,
            WorkspaceInfo info, 
            bool verboseLogging,
            bool isTestMode)
            : base(e, n,a, info, factory,presets, resolver)
        {
            EvaluationCount = 0;

            // This protects the user from a file that might have crashed during
            // its last run.  As a side effect, this also causes all files set to
            // run auto but lacking the HasRunWithoutCrash flag to run manually.
            if (info.RunType == RunType.Automatic && !info.HasRunWithoutCrash)
            {
                info.RunType = RunType.Manual;
            }

            RunSettings = new RunSettings(info.RunType, info.RunPeriod);

            PreloadedTraceData = traceData;

            this.scheduler = scheduler;
            this.verboseLogging = verboseLogging;
            IsTestMode = isTestMode;
            EngineController = engine;

            // The first time the preloaded trace data is set, we cache
            // the data as historical. This will be used after the initial
            // run of this workspace, when the PreloadedTraceData has been
            // nulled, to check for node deletions and reconcile the trace data.
            // We do a deep copy of this data because the PreloadedTraceData is
            // later set to null before the graph update.
            var copiedData = new List<KeyValuePair<Guid, List<string>>>();
            foreach (var kvp in PreloadedTraceData)
            {
                var strings = kvp.Value.Select(string.Copy).ToList();
                copiedData.Add(new KeyValuePair<Guid, List<string>>(kvp.Key, strings));
            }
            historicalTraceData = copiedData;

        }
开发者ID:joespiff,项目名称:Dynamo,代码行数:49,代码来源:HomeWorkspaceModel.cs

示例15: RequestVisualUpdateAsync

 public override void RequestVisualUpdateAsync(
     IScheduler scheduler, EngineController engine, IRenderPackageFactory factory, bool forceUpdate = false)
 {
     //Do nothing
 }
开发者ID:norbertzsiros,项目名称:Dynamo,代码行数:5,代码来源:WatchImageCore.cs


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