bool TryGetFlowNodeParams(ref IScriptRegistrationParams registrationParams, Type type) { if (!type.GetMembers().Any(member => member.ContainsAttribute<PortAttribute>())) return false; var nodeRegistrationParams = new FlowNodeRegistrationParams(); FlowNodeAttribute nodeInfo; if (type.TryGetAttribute(out nodeInfo)) { if (!string.IsNullOrEmpty(nodeInfo.UICategory)) nodeRegistrationParams.category = nodeInfo.UICategory; if (!string.IsNullOrEmpty(nodeInfo.Name)) nodeRegistrationParams.name = nodeInfo.Name; } registrationParams = nodeRegistrationParams; return true; }
bool TryGetFlowNodeParams(ref IScriptRegistrationParams registrationParams, Type type) { var nodeRegistrationParams = new FlowNodeRegistrationParams(); var inputs = new Dictionary<InputPortConfig, MethodInfo>(); var outputs = new Dictionary<OutputPortConfig, MemberInfo>(); var setFilter = false; var setTargetEntity = false; var setType = false; var nodeType = type; while (nodeType != typeof(FlowNode)) { FlowNodeAttribute nodeAttribute; if (nodeType.TryGetAttribute(out nodeAttribute)) { if(nodeRegistrationParams.category == null) nodeRegistrationParams.category = nodeAttribute.Category; if (nodeRegistrationParams.name == null) nodeRegistrationParams.name = nodeAttribute.Name; if (nodeRegistrationParams.description == null) nodeRegistrationParams.description = nodeAttribute.Description; if (!setFilter) { nodeRegistrationParams.filter = nodeAttribute.Filter; setFilter = true; } if (!setTargetEntity) { nodeRegistrationParams.hasTargetEntity = nodeAttribute.TargetsEntity; setTargetEntity = true; } if (!setType) { nodeRegistrationParams.type = nodeAttribute.Type; setType = true; } } TryGetFlowNodePorts(nodeType, ref inputs, ref outputs); nodeType = nodeType.BaseType; } if (inputs.Count == 0 && outputs.Count == 0) return false; nodeRegistrationParams.InputPorts = inputs.Keys.ToArray(); nodeRegistrationParams.OutputPorts = outputs.Keys.ToArray(); nodeRegistrationParams.InputMethods = inputs.Values.ToArray(); nodeRegistrationParams.OutputMembers = outputs.Values.ToArray(); registrationParams = nodeRegistrationParams; return true; }