/// <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));
        }
        /// <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));
        }
示例#3
0
        /// <summary>
        /// DynamoModel calls this method prior to scheduling a graph update for
        /// the home workspace. This method is called to schedule custom node 
        /// compilation since the home workspace update may depend on it. Any 
        /// updates to a CustomNodeDefinition will cause GraphSyncData to be added 
        /// to "pendingCustomNodeSyncData" queue.
        /// </summary>
        /// <param name="scheduler">The scheduler on which custom node compilation 
        /// task can be scheduled.</param>
        /// 
        internal void ProcessPendingCustomNodeSyncData(IScheduler scheduler)
        {
            while (pendingCustomNodeSyncData.Count > 0)
            {
                var initParams = new CompileCustomNodeParams
                {
                    SyncData = pendingCustomNodeSyncData.Dequeue(),
                    EngineController = this
                };

                var compileTask = new CompileCustomNodeAsyncTask(scheduler);
                if (compileTask.Initialize(initParams))
                    scheduler.ScheduleForExecution(compileTask);
            }
        }