Esempio n. 1
0
        //TODO: split RpcProxyRouter and RpcCallbackProxy
        public ClientRuntime(string address, ServiceEndpoint endpoint, bool callback = false, InstanceContext context = null, Guid customUuid = default(Guid), Type generatedProxyType = null)
        {
            _endpoint      = endpoint;
            _binding       = endpoint._binding;
            _serializer    = _binding.Serializer;
            _typeOfService = endpoint._contractType;
            _context       = context;
            if (_context != null && _context._useSynchronizationContext)
            {
                _syncContext = SynchronizationContext.Current;
            }
            _generatedProxyType = generatedProxyType;

            _address = address;

            _operations = DispatchTableFactory.GetOperations(_typeOfService);


            _uuid = EndpointMapper.CreateUuid(_address, _typeOfService);
            if (customUuid != Guid.Empty) // callback proxy
            {
                _uuid = customUuid;
            }

            var serviceContract = AttributesReader.GetServiceContract(_typeOfService);

            //TODO: null check only for duplex callback, really should always be here
            if (serviceContract != null && serviceContract.SessionMode == SessionMode.Required)
            {
                _session = Guid.NewGuid().ToString();
            }
            //TODO: allow to be initialized with pregenerated proxy
            var realProxy = new RpcRealProxy(_typeOfService, this, _endpoint, _encoder);

            _remote = realProxy.GetTransparentProxy();
            _client = RpcRequestReplyChannelFactory.CreateClient(_binding, _uuid, _address);
            foreach (var behavior in _endpoint.Behaviors)
            {
                behavior.ApplyClientBehavior(_endpoint, this);
            }
        }
Esempio n. 2
0
 protected EndpointDispatcher(object singletonService, ServiceEndpoint endpoint)
 {
     _endpoint         = endpoint;
     _singletonService = singletonService;
     _operations       = DispatchTableFactory.GetOperations(endpoint._contractType);
 }