protected override void RegisterPorts()
        {
            delegateType = delegateType != null ? delegateType : typeof(Delegate);
            delegatePort = AddValueOutput(delegateType.FriendlyName(), "Delegate", delegateType, () => { return(reflectedEvent.AsDelegate()); });
            callbackPort = AddFlowOutput("Callback");
            if (delegateType == typeof(Delegate))
            {
                return;
            }

            if (reflectedEvent == null)
            {
                reflectedEvent = new ReflectedDelegateEvent(delegateType);
                reflectedEvent.Add(Callback);
            }

            var parameters = delegateType.RTGetDelegateTypeParameters();

            for (var _i = 0; _i < parameters.Length; _i++)
            {
                var i         = _i;
                var parameter = parameters[i];
                AddValueOutput(parameter.Name, "arg" + i, parameter.ParameterType, () => { return(args[i]); });
            }
        }
        protected override void RegisterPorts()
        {
            type       = type != null? type : typeof(SharpEvent);
            eventInput = AddValueInput("Event", type);
            if (type == typeof(SharpEvent))
            {
                return;
            }

            var delegateType = type.RTGetGenericArguments()[0];

            if (reflectedEvent == null)
            {
                reflectedEvent = new ReflectedDelegateEvent(delegateType);
            }
            var parameters = delegateType.RTGetDelegateTypeParameters();

            for (var _i = 0; _i < parameters.Length; _i++)
            {
                var i         = _i;
                var parameter = parameters[i];
                AddValueOutput(parameter.Name, "arg" + i, parameter.ParameterType, () => { return(argValues[i]); });
            }

            flowCallback = AddFlowOutput("Callback");
            if (!autoHandleRegistration)
            {
                AddFlowInput("Register", Register, "Add");
                AddFlowInput("Unregister", Unregister, "Remove");
            }
        }
        protected override void RegisterPorts()
        {
            if (eventInfo == null)
            {
                return;
            }

            var delegateType = eventInfo.EventHandlerType;

            if (reflectedEvent == null)
            {
                reflectedEvent = new ReflectedDelegateEvent(delegateType);
            }

            if (!isStaticEvent)
            {
                instancePort = AddValueInput(eventInfo.RTReflectedOrDeclaredType().FriendlyName(), eventInfo.RTReflectedOrDeclaredType(), "Instance");
            }

            var parameters = delegateType.RTGetDelegateTypeParameters();

            args = new object[parameters.Length];
            for (var _i = 0; _i < parameters.Length; _i++)
            {
                var i         = _i;
                var parameter = parameters[i];
                AddValueOutput(parameter.Name, "arg" + i, parameter.ParameterType, () => { return(args[i]); });
            }

            callback = AddFlowOutput(eventInfo.Name, "Event");
        }
Example #4
0
 ///Stop listening from a reflected delegate event using this wrapper
 public void StopListening(ReflectedDelegateEvent reflectedEvent, ReflectedDelegateEvent.DelegateEventCallback callback)
 {
     if (reflectedEvent == null || callback == null)
     {
         return;
     }
     reflectedEvent.Remove(callback);
     eventInfo.RemoveEventHandler(instance, reflectedEvent.AsDelegate());
 }