Exemplo n.º 1
0
        public ServiceProxyInterceptor(
            Type serviceType,
            IServiceResolver serviceResolver,
            RpcHandler handler,
            RpcMethodFixture fixture,
            IServiceLoadBalancingStrategy strategy)
        {
            _serviceType     = serviceType;
            _serviceResolver = serviceResolver;

            _handler  = handler;
            _fixture  = fixture;
            _strategy = strategy;
        }
Exemplo n.º 2
0
        public ServiceActor Resolve(Type serviceType, IServiceLoadBalancingStrategy strategy)
        {
            if (serviceType == null)
            {
                throw new ArgumentNullException("serviceType");
            }
            if (strategy == null)
            {
                throw new ArgumentNullException("strategy");
            }

            var services = _retriever.Retrieve(serviceType);

            return(strategy.Select(services));
        }
Exemplo n.º 3
0
 public T Resolve <T>(IServiceLoadBalancingStrategy strategy)
 {
     return(_proxyGenerator.CreateServiceProxy <T>(this, _methodFixture, strategy));
 }
Exemplo n.º 4
0
        public T CreateServiceProxy <T>(RpcHandler handler, RpcMethodFixture fixture, IServiceLoadBalancingStrategy strategy)
        {
            var proxy = _proxyGenerator.CreateInterfaceProxyWithoutTarget(
                typeof(T),
                new ProxyGenerationOptions(),
                new IInterceptor[]
            {
                new ServiceProxyInterceptor(
                    typeof(T),
                    _serviceResolver,
                    handler,
                    fixture,
                    strategy)
            });

            return((T)proxy);
        }