Beispiel #1
0
 /// <summary>
 /// Loads parameters into an existing node
 /// </summary>
 /// <param name="nodeData">Serialised node parameters</param>
 public virtual void LoadParameters(Models.ExecutionGraph.Node nodeData)
 {
     if (nodeData.Data != null)
     {
         _ReadFrom(nodeData.Data, reader => ReadFrom(null, reader));
     }
 }
Beispiel #2
0
        /// <summary>
        /// Serialise this node and any connected nodes
        /// </summary>
        /// <param name="existing">Set of nodes that have already been serialised in the current context</param>
        /// <param name="connectedTo">List of nodes this node is connected to</param>
        /// <param name="wireList">List of wires between all connected nodes</param>
        /// <returns></returns>
        public virtual Models.ExecutionGraph.Node SerialiseTo(HashSet <INode> existing, List <Models.ExecutionGraph.Node> connectedTo, HashSet <Models.ExecutionGraph.Wire> wireList)
        {
            var info = _GetInfo();
            var ret  = new Models.ExecutionGraph.Node {
                Id          = _id,
                Name        = _name,
                Data        = info.Data,
                Description = info.Description,
                TypeName    = GetType().AssemblyQualifiedName
            };

            // get the connected nodes
            if (connectedTo != null && wireList != null)
            {
                foreach (var wire in Output)
                {
                    var sendTo = wire.SendTo;
                    wireList.Add(new Models.ExecutionGraph.Wire {
                        FromId       = _id,
                        InputChannel = wire.Channel,
                        ToId         = sendTo.Id
                    });
                    if (existing.Add(sendTo))
                    {
                        connectedTo.Add(sendTo.SerialiseTo(existing, connectedTo, wireList));
                    }
                }
            }
            return(ret);
        }
        /// <summary>
        /// Creates a node from it's serialised model
        /// </summary>
        /// <param name="node">The node model</param>
        public INode Create(Models.ExecutionGraph.Node node)
        {
            var type = Type.GetType(node.TypeName);
            var ret  = (INode)FormatterServices.GetUninitializedObject(type);

            ret.Initialise(this, node.Id, node.Name, node.Description, node.Data);
            return(ret);
        }