using System; using System.Collections.Generic; using System.Reflection; using Codice.Client.Common.TreeGrouper; using TNodeCore.Attribute.Ports; using TNodeCore.Models; using TNodeCore.RuntimeCache; namespace TNodeCore.Runtime{ public class RuntimeNode{ public NodeData NodeData { get; set; } //the link connect to node's in port public List InputLink = new List(); //the link connect to node's out port public List OutputLink = new List(); //Cache node data type for fast access private readonly Type _type; public void SetInput(string portName,object value){ _portAccessors[portName].SetValue(this.NodeData,value); } public object GetOutput(string portName){ return _portAccessors[portName].GetValue(this.NodeData); } private readonly Dictionary _portAccessors; public RuntimeNode(NodeData nodeData){ NodeData = nodeData; //Caching the type of the node _type = nodeData.GetType(); var info = nodeData.GetType().GetProperties(); _portAccessors = RuntimeCache.RuntimeCache.Instance.CachedPropertyAccessors[_type]; } public List GetInputNodesId(){ List dependencies = new List(); foreach (NodeLink link in InputLink) { dependencies.Add(link.outPort.nodeDataId); } return dependencies; } } }