Ejemplo n.º 1
0
        public IoResponseSchema GetInputsAndOutputs()
        {
            // Parse input and output names
            List <string> inputNames  = new List <string>();
            List <string> outputNames = new List <string>();
            var           inputs      = new List <InputParamSchema>();
            var           outputs     = new List <IoParamSchema>();

            foreach (var i in _input)
            {
                inputNames.Add(i.Key);
                var inputSchema = new InputParamSchema
                {
                    Name        = i.Key,
                    ParamType   = ParamTypeName(i.Value.Param),
                    Description = i.Value.GetDescription(),
                    AtLeast     = i.Value.GetAtLeast(),
                    AtMost      = i.Value.GetAtMost(),
                    Default     = i.Value.GetDefault(),
                    Minimum     = i.Value.GetMinimum(),
                    Maximum     = i.Value.GetMaximum(),
                };
                if (_singularComponent != null)
                {
                    inputSchema.Description = i.Value.Param.Description;
                    if (i.Value.Param.Access == GH_ParamAccess.item)
                    {
                        inputSchema.AtMost = inputSchema.AtLeast;
                    }
                }
                inputs.Add(inputSchema);
            }

            foreach (var o in _output)
            {
                outputNames.Add(o.Key);
                outputs.Add(new IoParamSchema
                {
                    Name      = o.Key,
                    ParamType = o.Value.TypeName
                });
            }

            string description = _singularComponent == null ?
                                 Definition.Properties.Description :
                                 _singularComponent.Description;

            return(new IoResponseSchema
            {
                Description = description,
                InputNames = inputNames,
                OutputNames = outputNames,
                Inputs = inputs,
                Outputs = outputs
            });
        }
Ejemplo n.º 2
0
 internal static GH_ParamAccess AccessFromInput(InputParamSchema input)
 {
     if (input.AtLeast == 1 && input.AtMost == 1)
     {
         return(GH_ParamAccess.item);
     }
     if (input.AtLeast == -1 && input.AtMost == -1)
     {
         return(GH_ParamAccess.tree);
     }
     return(GH_ParamAccess.list);
 }