Exemple #1
0
        public IIncomingInvocation <TRequest, TResponse> CreateAsync <TRequest, TResponse>(IncomingInvocationDescriptor info, ITransportChannel channel)
        {
            var invocation = new IncomingInvocation <TRequest, TResponse>(
                info,
                channel,
                _protocol,
                _marshaller.GetMarshaller <TRequest>(),
                _marshaller.GetMarshaller <TResponse>());

            invocation.Start();
            return(invocation);
        }
Exemple #2
0
        public async ValueTask <IOutcomingInvocation <TRequest, TResponse> > CreateAsync <TRequest, TResponse>(
            MethodCallDescriptor methodCall, Maybe <TRequest> request = default)
        {
            var channel = await _connection.CreateChannelAsync().ConfigureAwait(false);

            InvocationMethodDescriptor methodDescriptor = null;
            InvocationTargetDescriptor targetDescriptor = null;

            if (methodCall.Method.HasValue)
            {
                var method = methodCall.Method.Value;
                methodDescriptor = new InvocationMethodDescriptor(method.Service.Id, method.Name, method.Service.Alias);
            }
            if (methodCall.ProvidedMethod.HasValue)
            {
                var method = methodCall.ProvidedMethod.Value;
                methodDescriptor = new InvocationMethodDescriptor(method.ProvidedService.ServiceId, method.Name, method.ProvidedService.ServiceId);
                targetDescriptor = new InvocationTargetDescriptor(method.ProvidedService.ApplicationId, method.ProvidedService.ConnectionId, method.ProvidedService.ServiceAlias);
            }
            var descriptor = new OutcomingInvocationDescriptor(methodDescriptor, targetDescriptor);
            var invocation = new OutcomingInvocation <TRequest, TResponse>(
                descriptor,
                channel,
                _protocol,
                _marshaller.GetMarshaller <TRequest>(),
                _marshaller.GetMarshaller <TResponse>());

            invocation.Start();
            if (request.HasValue)
            {
                await invocation.Out.WriteAsync(request.Value).ConfigureAwait(false);

                invocation.Out.TryComplete();
            }
            return(invocation);
        }
 private IMarshaller <T> GetMarshaller <T>()
 {
     return(typeof(T) == typeof(Nothing)
         ? (IMarshaller <T>)NothingMarshaller.Instance
         : _marshaller.GetMarshaller <T>());
 }