protected void Execute(object[] eventArgs) { if (m_nodes.Count <= 0) { return; } if (!(m_nodes[0] is CReceiveEventNode eventTargetNode)) { throw new Exception("The first node of an event graph must always be a ReceiveEventNode"); } PrepareStack(); m_inParameterBuffer.Clear(); m_outParameterBuffer.Clear(); if (eventArgs != null) { foreach (object arg in eventArgs) { m_inParameterBuffer.Add(arg); } } CGraph oldContextGraph = s_nodeExecutionContext.graph; CExecutionPin oldCalledPin = s_nodeExecutionContext.calledPin; s_nodeExecutionContext.graph = this; s_nodeExecutionContext.calledPin = null; CExecutionPin nextExecPin = eventTargetNode.Execute(s_nodeExecutionContext, m_inParameterBuffer, m_outParameterBuffer); m_inParameterBuffer.Clear(); if (nextExecPin != null && nextExecPin.TargetNode != null) { AddOutParametersToStack(eventTargetNode.OutParameterStackIndex, eventTargetNode.GetOutParameterCount()); m_outParameterBuffer.Clear(); Execute(nextExecPin.TargetNode, nextExecPin); } s_nodeExecutionContext.graph = oldContextGraph; s_nodeExecutionContext.calledPin = oldCalledPin; }
public void ExecuteGraph(CGraph graph) { }
public void Execute(List <object> inValues, List <object> outValues) { if (m_nodes.Count <= 0) { return; } CFunctionGraphEntryNode entryNode = m_nodes[0] as CFunctionGraphEntryNode; if (entryNode == null) { throw new Exception("The first node of a function graph has to be an entry node"); } if (inValues.Count != NumInputValues) { throw new Exception($"Number of input values does not match the expected number on inputs. In Count was {inValues.Count} expected was {NumInputValues}"); } outValues.Clear(); outValues.Capacity = NumOutputValues; PrepareStack(); m_inParameterBuffer.Clear(); m_outParameterBuffer.Clear(); foreach (var inValue in inValues) { m_inParameterBuffer.Add(inValue); } CGraph oldContextGraph = s_nodeExecutionContext.graph; CExecutionPin oldCalledPin = s_nodeExecutionContext.calledPin; s_nodeExecutionContext.graph = this; s_nodeExecutionContext.calledPin = null; CExecutionPin nextExecPin = entryNode.Execute(s_nodeExecutionContext, m_inParameterBuffer, m_outParameterBuffer); if (nextExecPin?.TargetNode != null) { AddOutParametersToStack(entryNode.OutParameterStackIndex, entryNode.GetOutParameterCount()); CNode lastNode = Execute(nextExecPin.TargetNode, nextExecPin); if (lastNode is CFunctionGraphReturnNode) { // Out buffer contains the return values of the return nodes foreach (var outValue in m_outParameterBuffer) { outValues.Add(outValue); } } else { for (int i = 0; i < NumOutputValues; i++) { outValues.Add(null); } } } s_nodeExecutionContext.graph = oldContextGraph; s_nodeExecutionContext.calledPin = oldCalledPin; }