/// <summary>
        ///
        /// </summary>
        public DirectProxyFactory()
        {
            EmptyProxyFactory.MethodCalled += (sender, args) =>
            {
                if (sender == null ||
                    !Dictionary.TryGetValue(sender, out var obj))
                {
                    return;
                }

                MethodCalled?.Invoke(sender, args);

                if (args.IsCanceled)
                {
                    return;
                }

                var method = obj.GetType().GetMethod(args.MethodInfo.Name, args.MethodInfo
                                                     .GetParameters()
                                                     .Select(i => i.ParameterType)
                                                     .ToArray())
                             ?? throw new InvalidOperationException($"Method not found: {args.MethodInfo}");

                args.ReturnObject = method.Invoke(obj, args.Arguments.ToArray());

                MethodCompleted?.Invoke(sender, args);
            };
            EmptyProxyFactory.EventRaised    += (sender, args) => EventRaised?.Invoke(this, args);
            EmptyProxyFactory.EventCompleted += (sender, args) => EventCompleted?.Invoke(this, args);
        }
示例#2
0
        private void UXEvent_OnCompleted(IUXEvent uxEvent)
        {
            // Remove from currently running list
            _runningEvents.Remove(uxEvent);

            // Unsubscribe from event
            uxEvent.Completed -= UXEvent_OnCompleted;

            // Fire off our own event
            EventCompleted?.Invoke(uxEvent);
        }
示例#3
0
 /// <summary>
 /// Invokes handlers of the <see cref="EventCompleted"/> event.
 /// </summary>
 /// <param name="completionArgs">The event completion data.</param>
 protected virtual void OnNotifyEventCompletedAsync(object completionArgs)
 {
     EventCompleted?.Invoke(this, new SolutionPresenterEventCompletedEventArgs(EventContext, completionArgs));
 }