public ParamInfoOutput Clone(NodeParam newParam)
        {
            ParamInfoOutput p = new ParamInfoOutput()
            {
                OutputFieldName = OutputFieldName,
                Desc            = Desc,
                OutputType      = OutputType,
                OutputName      = OutputName,
            };

            p.SrcParam = newParam;
            return(p);
        }
Beispiel #2
0
        public void AddParam(Type type, ParamInfoOutput info)
        {
            if (!_paramsInfo.ContainsKey(type))
            {
                _paramsInfo.Add(type, new List <ParamInfoOutput>());
            }
            List <ParamInfoOutput> list = _paramsInfo[type];

            for (int i = 0; i < list.Count; ++i)
            {
                ParamInfoOutput output = list[i];
                if (output.OutputName == info.OutputName)
                {
                    list[i] = info;
                    return;
                }
            }
            list.Add(info);
        }
Beispiel #3
0
        /// <summary>
        /// 初始化客户端节点
        /// </summary>
        public static void InitClient()
        {
            Type[] types = typeof(Node).Assembly.GetTypes();
            foreach (Type type in types)
            {
                object[] objs = type.GetCustomAttributes(typeof(NodeAttribute), false);
                foreach (NodeAttribute attr in objs)
                {
                    NodeParam p = new NodeParam()
                    {
                        NodeType      = type,
                        TypeDesc      = attr.Desc,
                        NodeClassType = attr.ClassifytType
                    };

                    FieldInfo[] fields = type.GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic);
                    foreach (FieldInfo field in fields)
                    {
                        NodeFieldAttribute fieldAttr = field.GetCustomAttribute <NodeFieldAttribute>();
                        if (fieldAttr != null)
                        {
                            Type      envKeyType = fieldAttr.envKeyType == null ? field.FieldType : fieldAttr.envKeyType;
                            ParamInfo pInfo      = new ParamInfo(field.Name, fieldAttr.Desc, envKeyType, fieldAttr.DefaultValue);
                            p.Fields.Add(pInfo);
                            continue;
                        }

                        NodeInputAttribute inputAttr = field.GetCustomAttribute <NodeInputAttribute>();
                        if (inputAttr != null)
                        {
                            ParamInfoInput pInput = new ParamInfoInput()
                            {
                                InputFieldName = field.Name,
                                Desc           = inputAttr.Desc,
                                InputType      = inputAttr.envKeyType,
                                SrcInputStr    = inputAttr.DefaultValue as string
                            };
                            p.Inputs.Add(pInput);
                            continue;
                        }

                        NodeOutputAttribute outputAttr = field.GetCustomAttribute <NodeOutputAttribute>();
                        if (outputAttr != null)
                        {
                            ParamInfoOutput pInfo = new ParamInfoOutput()
                            {
                                OutputFieldName = field.Name,
                                Desc            = outputAttr.Desc,
                                OutputType      = outputAttr.envKeyType,
                                OutputName      = outputAttr.DefaultValue as string
                            };
                            p.Outputs.Add(pInfo);
                        }
                    }

                    if (attr.ClassifytType == NodeClassifyType.Error)
                    {
                        _errorNode = p;
                    }
                    else
                    {
                        _clientNodes.Add(type, p);
                    }
                }
            }
        }