Exemple #1
0
        private static NetGraph CreateGraph(string name, Logger logger, NetGraph parent, MetaDictionary globalMeta, MetaDictionary meta,
                                            IEnumerable <GraphNodeEntry> nodes, IEnumerable <GraphLineEntry> lines, Dictionary <string, string> props, PropertyBag connectionProperties,
                                            Dictionary <string, object> stateDictionary)
        {
            NetGraph       netGraph        = new NetGraph(logger, parent, globalMeta, meta, connectionProperties);
            HashSet <Guid> referencedNodes = new HashSet <Guid>();

            netGraph.Name = name != null ? name : String.Empty;

            foreach (GraphNodeEntry n in nodes)
            {
                BasePipelineNode pipeNode = n.Factory.Create(logger, netGraph, stateDictionary);
                if (pipeNode == null)
                {
                    throw new InvalidOperationException("One of the nodes failed to create");
                }

                pipeNode.Graph = netGraph;
                pipeNode.Name  = n.Factory.Label;
                pipeNode.Uuid  = n.Id;
                netGraph.AddNode(n.Factory.Id, pipeNode);
            }

            foreach (GraphLineEntry l in lines)
            {
                netGraph.Nodes[l.SourceNode].AddOutput(netGraph.Nodes[l.DestNode], l.PathName, l.WeakPath);
                referencedNodes.Add(l.DestNode);

                if (l.BiDirection)
                {
                    netGraph.Nodes[l.DestNode].AddOutput(netGraph.Nodes[l.SourceNode], l.PathName, l.WeakPath);
                }
            }

            foreach (KeyValuePair <string, string> pair in props)
            {
                netGraph.Meta[pair.Key] = pair.Value;
            }

            foreach (Guid uuid in referencedNodes)
            {
                BasePipelineNode node = netGraph.Nodes[uuid];

                node.SetupShutdownOutputs();

                //foreach (BasePipelineNode output in node.Outputs)
                //{
                //    output.AddShutdownInput(node);
                //}
            }

            return(netGraph);
        }