Example #1
0
 /// <summary>
 ///
 /// </summary>
 /// <typeparam name="TRequest"></typeparam>
 /// <typeparam name="TResponse"></typeparam>
 /// <param name="method"></param>
 /// <param name="handler"></param>
 protected void AddStructMethod <TRequest, TResponse>(Method <TRequest, TResponse> method, StructUnaryServerMethod <TRequest, TResponse> handler)
 {
     m_Service = m_Service.AddStructMethod(method, handler);
 }
        /// <summary>
        /// Adds a definition for a single request - single response method without type restrictions.
        /// </summary>
        /// <typeparam name="TRequest">The type of the request.</typeparam>
        /// <typeparam name="TResponse">The type of the response.</typeparam>
        /// <param name="builder"></param>
        /// <param name="method"></param>
        /// <param name="handler"></param>
        /// <returns></returns>
        public static ServerServiceDefinition.Builder AddStructMethod <TRequest, TResponse>(this ServerServiceDefinition.Builder builder, Method <TRequest, TResponse> method, StructUnaryServerMethod <TRequest, TResponse> handler)
        {
            async Task <byte[]> func(byte[] request, ServerCallContext context)
            {
                TResponse response = await handler(method.RequestMarshaller.Deserializer(request), context).ConfigureAwait(false);

                return(method.ResponseMarshaller.Serializer(response));
            };

            return(builder.AddMethod(s_StructMethodCache.GetMethod(method), func));
        }