Exemplo n.º 1
0
        public InternalEventResult InvokeWithData(dynamic?data, DataOrigin dataOrigin, IDataHistoryNode?histNode)
        {
            var obj = (object?)data;

            if (obj is T tval)
            {
                return(InvokeWithData(tval, dataOrigin, histNode));
            }
            if (obj is IUsableAs <T> usable)
            {
                return(InvokeWithUsableData(usable, dataOrigin, histNode));
            }

            var @event = new TypedInvokedEvent1 <T>(dataOrigin, handler.Event, this, obj, histNode);

            ExceptionDispatchInfo?caught = null;

            try
            {
                handler.HandlerFunc.Invoke(@event, Maybe.None);
            }
            catch (Exception e)
            {
                caught = ExceptionDispatchInfo.Capture(e);
            }

            if (@event.AlwaysInvokeNext && [email protected])
            {
                var result = InvokeContinuationDynamic((object?)data, dataOrigin, histNode);
                caught = InternalEventResult.CombineExceptions(caught, result.Exception);
            }

            return(new InternalEventResult(@event.GetEventResult(), caught));
        }
Exemplo n.º 2
0
        public InternalEventResult InvokeWithData(dynamic?data, DataOrigin dataOrigin, IDataHistoryNode?lastNode)
        {
            var @event = new DynamicInvokedEvent(dataOrigin, handler.Event, this, (object?)data, lastNode);

            ExceptionDispatchInfo?caught = null;

            try
            {
                handler.HandlerFunc.Invoke(@event, (object?)data);
            }
            catch (Exception e)
            {
                caught = ExceptionDispatchInfo.Capture(e);
            }

            if (@event.AlwaysInvokeNext && [email protected])
            {
                var result = InvokeContinuation((object?)data, dataOrigin, lastNode);
                caught = InternalEventResult.CombineExceptions(caught, result.Exception);
            }

            return(new InternalEventResult(@event.GetEventResult(), caught));
        }