public static IValuePort GetOrCreatePort(this IValuePortAttribute self, INode node) { var port = (IValuePort)((IPortAttribute)self).GetOrCreatePort(node); port.Definition(node, self); return(port); }
public void Definition(INode node, IValuePortAttribute info) { Id = new PortId(node.NodeId, info.Name); Node = node; Name = info.Name; Direction = info.Direction; Capacity = info.Capacity; GraphPort = info.GraphPort; ValueType = typeof(T); if (info.CallbackInfo == null) { return; } var parameters = info.CallbackInfo.GetParameters(); if (parameters.Length > 0) { Debug.LogWarning($"ValuePort Callback for '{node}.{info.CallbackInfo.Name}' has {parameters.Length} parameter(s). Callback cannot accept any parameters"); return; } if (VoidType.IsAssignableFrom(info.CallbackInfo.ReturnType)) { _simpleCallback = (Action)info.CallbackInfo.CreateDelegate(SimpleCallbackType, node); _callbackType = CallbackTypes.Simple; } if (ValueType.IsAssignableFrom(info.CallbackInfo.ReturnType)) { _valueCallback = (Func <T>)info.CallbackInfo.CreateDelegate(ValueCallbackType, node); _callbackType = CallbackTypes.Value; } if (_callbackType == CallbackTypes.None) { Debug.LogWarning($"ValuePort Callback for '{node}.{info.CallbackInfo.Name}' did not have one of the following method signatures [Action, Func<T>]"); } }