private T CreateEvents <T>(IEventInterceptor interceptor)
        {
            var proxyBuilder = new ProxyFactoryBuilder(typeof(T));

            proxyBuilder.InterceptEvents();
            return(proxyBuilder.Build().Create <T>(asyncInterceptor: null, eventInterceptor: interceptor));
        }
        public void AddInterceptor(IEventInterceptor intercept)
        {
            lock (_interceptors)
            {
                if (false == _interceptors.ContainsKey(intercept.Topic))
                {
                    _interceptors.Add(intercept.Topic, new List<IEventInterceptor>());
                }

                _interceptors[intercept.Topic].Add(intercept);
            }
        }
Ejemplo n.º 3
0
 public BatchRepaymentPresenter(
     IBatchRepaymentView view,
     ILoanRepository loanRepository,
     IVillageBankRepository villageBankRepository,
     IEventInterceptor eventInterceptor,
     IConnectionProvider connectionProvider,
     IApplicationController applicationController)
 {
     _view = view;
     _loanRepository = loanRepository;
     _villageBankRepository = villageBankRepository;
     _eventInterceptor = eventInterceptor;
     _connectionProvider = connectionProvider;
     _applicationController = applicationController;
 }
Ejemplo n.º 4
0
 public BatchRepaymentPresenter(
     IBatchRepaymentView view,
     ILoanRepository loanRepository,
     IVillageBankRepository villageBankRepository,
     IEventInterceptor eventInterceptor,
     IConnectionProvider connectionProvider,
     IApplicationController applicationController)
 {
     _view                  = view;
     _loanRepository        = loanRepository;
     _villageBankRepository = villageBankRepository;
     _eventInterceptor      = eventInterceptor;
     _connectionProvider    = connectionProvider;
     _applicationController = applicationController;
 }
        public object Create(IAsyncInterceptor asyncInterceptor, IEventInterceptor eventInterceptor)
        {
            var result = Activator.CreateInstance(_proxyImplementation);

            if (InterceptedMethods != null)
            {
                var asyncProxy = (IAsyncInterceptorProxy)result;
                asyncProxy.Interceptor = asyncInterceptor ?? throw new ArgumentNullException(nameof(asyncInterceptor));
                asyncProxy.Methods     = InterceptedMethods.ToArray();
            }

            if (InterceptedEvents != null)
            {
                var eventProxy = (IEventInterceptorProxy)result;
                eventProxy.Interceptor = eventInterceptor ?? throw new ArgumentNullException(nameof(asyncInterceptor));
                eventProxy.Events      = InterceptedEvents.ToArray();
            }

            return(result);
        }
Ejemplo n.º 6
0
 internal void AddInterceptor(IEventInterceptor eventInterceptor)
 {
     _eventInterceptors.Add(eventInterceptor);
 }
Ejemplo n.º 7
0
 public static TInterface Create(IAsyncInterceptor asyncInterceptor, IEventInterceptor eventInterceptor) =>
 ProxyFactory.Create <TInterface>(asyncInterceptor, eventInterceptor);
 public T Create <T>(IAsyncInterceptor asyncInterceptor, IEventInterceptor eventInterceptor) =>
 (T)Create(asyncInterceptor, eventInterceptor);
 public void RemoveInterceptor(IEventInterceptor intercept)
 {
     lock (_interceptors)
     {
         if (_interceptors.ContainsKey(intercept.Topic))
         {
             if (_interceptors[intercept.Topic].Contains(intercept))
             {
                 _interceptors[intercept.Topic].Remove(intercept);
             }
         }
     }
 }
Ejemplo n.º 10
0
        public static T InitializeEventProxy <T>(EventProxyInitializationInfo initializationInfo, IEventInterceptor eventInterceptor)
        {
            var result = (T)Activator.CreateInstance(initializationInfo.ProxyType.AsType());

            var proxy = (IEventInterceptorProxy)result;

            proxy.Interceptor = eventInterceptor;
            proxy.Events      = initializationInfo.Events;

            return(result);
        }