public IncomingInvocationDescriptor(
     InvocationMethodDescriptor method,
     InvocationSourceDescriptor source)
 {
     Method = method;
     Source = source;
 }
        public async ValueTask <IOutcomingInvocation <TRequest, TResponse> > CreateAsync <TRequest, TResponse>(
            MethodCallDescriptor methodCall, Maybe <TRequest> request = default, Maybe <ContextLinkageOptions> contextLinkageOptions = 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, contextLinkageOptions);
            var invocation = new OutcomingInvocation <TRequest, TResponse>(
                descriptor,
                channel,
                _protocol,
                GetMarshaller <TRequest>(),
                GetMarshaller <TResponse>());

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

                invocation.Out.TryComplete();
            }
            return(invocation);
        }