Esempio n. 1
0
        public override void Validate()
        {
            //stack overflow prevent
            if (is_validating)
            {
                return;
            }
            is_validating = true;
            if (reference)
            {
                macro = this;

                input_node  = (InputNode)reference.graph.nodes.FirstOrDefault(n => n is InputNode);
                output_node = (OutputNode)reference.graph.nodes.FirstOrDefault(n => n is OutputNode);

                if (input_node)
                {
                    input_node.macro = this;
                }
                if (output_node)
                {
                    output_node.macro = this;
                }

                reference.Validate();
            }
            base.Validate();
            is_validating = false;
        }
Esempio n. 2
0
        public void OnRegisterDefaultPorts()
        {
            if (reference)
            {
                this.title    = this.name = "{ " + string.Format("{0}", reference.title.IsNullOrEmpty() ? reference.name : reference.title) + " }";
                this.subtitle = reference.subtitle;
                macro         = this;

                input_node  = (InputNode)reference.graph.nodes.FirstOrDefault(n => n is InputNode);
                output_node = (OutputNode)reference.graph.nodes.FirstOrDefault(n => n is OutputNode);

                if (input_node)
                {
                    input_node.macro = this;
                    input            = RegisterEntryPort("In", OnExecute);
                }
                if (output_node)
                {
                    output_node.macro = this;
                    output            = RegisterExitPort("Out");
                }

                if (macro)
                {
                    if (input_node)
                    {
                        input_acts   = new List <InputAction>();
                        input_values = new Dictionary <int, IInputValue>();
                        foreach (Parameter parameter in reference.graph.inputParameters)
                        {
                            if (parameter is ParameterInput)
                            {
                                input_acts.Add(RegisterEntryPort(parameter.name, () => { Call(input_node.output_acts[parameter.id]); }));
                            }
                            else
                            {
                                input_values[parameter.id] = (IInputValue)RegisterInputValue(parameter.valueType, parameter.name);
                            }
                        }
                    }
                    if (output_node)
                    {
                        output_acts   = new Dictionary <int, OutputAction>();
                        output_values = new List <IOutputValue>();
                        foreach (Parameter parameter in reference.graph.outputParameters)
                        {
                            if (parameter is ParameterOutput)
                            {
                                output_acts[parameter.id] = RegisterExitPort(parameter.name);
                            }
                            else
                            {
                                output_values.Add((IOutputValue)RegisterOutputValue(parameter.valueType, parameter.name, () => { return(output_node.input_values[parameter.id].GetValue()); }));
                            }
                        }
                    }
                }
            }
        }