MathGrpc.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. // <auto-generated>
  2. // Generated by the protocol buffer compiler. DO NOT EDIT!
  3. // source: math/math.proto
  4. // </auto-generated>
  5. // Original file comments:
  6. // Copyright 2015 gRPC authors.
  7. //
  8. // Licensed under the Apache License, Version 2.0 (the "License");
  9. // you may not use this file except in compliance with the License.
  10. // You may obtain a copy of the License at
  11. //
  12. // http://www.apache.org/licenses/LICENSE-2.0
  13. //
  14. // Unless required by applicable law or agreed to in writing, software
  15. // distributed under the License is distributed on an "AS IS" BASIS,
  16. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. // See the License for the specific language governing permissions and
  18. // limitations under the License.
  19. //
  20. #pragma warning disable 0414, 1591
  21. #region Designer generated code
  22. using grpc = global::Grpc.Core;
  23. namespace Math {
  24. public static partial class Math
  25. {
  26. static readonly string __ServiceName = "math.Math";
  27. static void __Helper_SerializeMessage(global::Google.Protobuf.IMessage message, grpc::SerializationContext context)
  28. {
  29. #if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION
  30. if (message is global::Google.Protobuf.IBufferMessage)
  31. {
  32. context.SetPayloadLength(message.CalculateSize());
  33. global::Google.Protobuf.MessageExtensions.WriteTo(message, context.GetBufferWriter());
  34. context.Complete();
  35. return;
  36. }
  37. #endif
  38. context.Complete(global::Google.Protobuf.MessageExtensions.ToByteArray(message));
  39. }
  40. static class __Helper_MessageCache<T>
  41. {
  42. public static readonly bool IsBufferMessage = global::System.Reflection.IntrospectionExtensions.GetTypeInfo(typeof(global::Google.Protobuf.IBufferMessage)).IsAssignableFrom(typeof(T));
  43. }
  44. static T __Helper_DeserializeMessage<T>(grpc::DeserializationContext context, global::Google.Protobuf.MessageParser<T> parser) where T : global::Google.Protobuf.IMessage<T>
  45. {
  46. #if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION
  47. if (__Helper_MessageCache<T>.IsBufferMessage)
  48. {
  49. return parser.ParseFrom(context.PayloadAsReadOnlySequence());
  50. }
  51. #endif
  52. return parser.ParseFrom(context.PayloadAsNewBuffer());
  53. }
  54. static readonly grpc::Marshaller<global::Math.DivArgs> __Marshaller_math_DivArgs = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Math.DivArgs.Parser));
  55. static readonly grpc::Marshaller<global::Math.DivReply> __Marshaller_math_DivReply = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Math.DivReply.Parser));
  56. static readonly grpc::Marshaller<global::Math.FibArgs> __Marshaller_math_FibArgs = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Math.FibArgs.Parser));
  57. static readonly grpc::Marshaller<global::Math.Num> __Marshaller_math_Num = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Math.Num.Parser));
  58. static readonly grpc::Method<global::Math.DivArgs, global::Math.DivReply> __Method_Div = new grpc::Method<global::Math.DivArgs, global::Math.DivReply>(
  59. grpc::MethodType.Unary,
  60. __ServiceName,
  61. "Div",
  62. __Marshaller_math_DivArgs,
  63. __Marshaller_math_DivReply);
  64. static readonly grpc::Method<global::Math.DivArgs, global::Math.DivReply> __Method_DivMany = new grpc::Method<global::Math.DivArgs, global::Math.DivReply>(
  65. grpc::MethodType.DuplexStreaming,
  66. __ServiceName,
  67. "DivMany",
  68. __Marshaller_math_DivArgs,
  69. __Marshaller_math_DivReply);
  70. static readonly grpc::Method<global::Math.FibArgs, global::Math.Num> __Method_Fib = new grpc::Method<global::Math.FibArgs, global::Math.Num>(
  71. grpc::MethodType.ServerStreaming,
  72. __ServiceName,
  73. "Fib",
  74. __Marshaller_math_FibArgs,
  75. __Marshaller_math_Num);
  76. static readonly grpc::Method<global::Math.Num, global::Math.Num> __Method_Sum = new grpc::Method<global::Math.Num, global::Math.Num>(
  77. grpc::MethodType.ClientStreaming,
  78. __ServiceName,
  79. "Sum",
  80. __Marshaller_math_Num,
  81. __Marshaller_math_Num);
  82. /// <summary>Service descriptor</summary>
  83. public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor
  84. {
  85. get { return global::Math.MathReflection.Descriptor.Services[0]; }
  86. }
  87. /// <summary>Base class for server-side implementations of Math</summary>
  88. [grpc::BindServiceMethod(typeof(Math), "BindService")]
  89. public abstract partial class MathBase
  90. {
  91. /// <summary>
  92. /// Div divides DivArgs.dividend by DivArgs.divisor and returns the quotient
  93. /// and remainder.
  94. /// </summary>
  95. /// <param name="request">The request received from the client.</param>
  96. /// <param name="context">The context of the server-side call handler being invoked.</param>
  97. /// <returns>The response to send back to the client (wrapped by a task).</returns>
  98. public virtual global::System.Threading.Tasks.Task<global::Math.DivReply> Div(global::Math.DivArgs request, grpc::ServerCallContext context)
  99. {
  100. throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
  101. }
  102. /// <summary>
  103. /// DivMany accepts an arbitrary number of division args from the client stream
  104. /// and sends back the results in the reply stream. The stream continues until
  105. /// the client closes its end; the server does the same after sending all the
  106. /// replies. The stream ends immediately if either end aborts.
  107. /// </summary>
  108. /// <param name="requestStream">Used for reading requests from the client.</param>
  109. /// <param name="responseStream">Used for sending responses back to the client.</param>
  110. /// <param name="context">The context of the server-side call handler being invoked.</param>
  111. /// <returns>A task indicating completion of the handler.</returns>
  112. public virtual global::System.Threading.Tasks.Task DivMany(grpc::IAsyncStreamReader<global::Math.DivArgs> requestStream, grpc::IServerStreamWriter<global::Math.DivReply> responseStream, grpc::ServerCallContext context)
  113. {
  114. throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
  115. }
  116. /// <summary>
  117. /// Fib generates numbers in the Fibonacci sequence. If FibArgs.limit > 0, Fib
  118. /// generates up to limit numbers; otherwise it continues until the call is
  119. /// canceled. Unlike Fib above, Fib has no final FibReply.
  120. /// </summary>
  121. /// <param name="request">The request received from the client.</param>
  122. /// <param name="responseStream">Used for sending responses back to the client.</param>
  123. /// <param name="context">The context of the server-side call handler being invoked.</param>
  124. /// <returns>A task indicating completion of the handler.</returns>
  125. public virtual global::System.Threading.Tasks.Task Fib(global::Math.FibArgs request, grpc::IServerStreamWriter<global::Math.Num> responseStream, grpc::ServerCallContext context)
  126. {
  127. throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
  128. }
  129. /// <summary>
  130. /// Sum sums a stream of numbers, returning the final result once the stream
  131. /// is closed.
  132. /// </summary>
  133. /// <param name="requestStream">Used for reading requests from the client.</param>
  134. /// <param name="context">The context of the server-side call handler being invoked.</param>
  135. /// <returns>The response to send back to the client (wrapped by a task).</returns>
  136. public virtual global::System.Threading.Tasks.Task<global::Math.Num> Sum(grpc::IAsyncStreamReader<global::Math.Num> requestStream, grpc::ServerCallContext context)
  137. {
  138. throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
  139. }
  140. }
  141. /// <summary>Client for Math</summary>
  142. public partial class MathClient : grpc::ClientBase<MathClient>
  143. {
  144. /// <summary>Creates a new client for Math</summary>
  145. /// <param name="channel">The channel to use to make remote calls.</param>
  146. public MathClient(grpc::ChannelBase channel) : base(channel)
  147. {
  148. }
  149. /// <summary>Creates a new client for Math that uses a custom <c>CallInvoker</c>.</summary>
  150. /// <param name="callInvoker">The callInvoker to use to make remote calls.</param>
  151. public MathClient(grpc::CallInvoker callInvoker) : base(callInvoker)
  152. {
  153. }
  154. /// <summary>Protected parameterless constructor to allow creation of test doubles.</summary>
  155. protected MathClient() : base()
  156. {
  157. }
  158. /// <summary>Protected constructor to allow creation of configured clients.</summary>
  159. /// <param name="configuration">The client configuration.</param>
  160. protected MathClient(ClientBaseConfiguration configuration) : base(configuration)
  161. {
  162. }
  163. /// <summary>
  164. /// Div divides DivArgs.dividend by DivArgs.divisor and returns the quotient
  165. /// and remainder.
  166. /// </summary>
  167. /// <param name="request">The request to send to the server.</param>
  168. /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
  169. /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
  170. /// <param name="cancellationToken">An optional token for canceling the call.</param>
  171. /// <returns>The response received from the server.</returns>
  172. public virtual global::Math.DivReply Div(global::Math.DivArgs request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
  173. {
  174. return Div(request, new grpc::CallOptions(headers, deadline, cancellationToken));
  175. }
  176. /// <summary>
  177. /// Div divides DivArgs.dividend by DivArgs.divisor and returns the quotient
  178. /// and remainder.
  179. /// </summary>
  180. /// <param name="request">The request to send to the server.</param>
  181. /// <param name="options">The options for the call.</param>
  182. /// <returns>The response received from the server.</returns>
  183. public virtual global::Math.DivReply Div(global::Math.DivArgs request, grpc::CallOptions options)
  184. {
  185. return CallInvoker.BlockingUnaryCall(__Method_Div, null, options, request);
  186. }
  187. /// <summary>
  188. /// Div divides DivArgs.dividend by DivArgs.divisor and returns the quotient
  189. /// and remainder.
  190. /// </summary>
  191. /// <param name="request">The request to send to the server.</param>
  192. /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
  193. /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
  194. /// <param name="cancellationToken">An optional token for canceling the call.</param>
  195. /// <returns>The call object.</returns>
  196. public virtual grpc::AsyncUnaryCall<global::Math.DivReply> DivAsync(global::Math.DivArgs request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
  197. {
  198. return DivAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken));
  199. }
  200. /// <summary>
  201. /// Div divides DivArgs.dividend by DivArgs.divisor and returns the quotient
  202. /// and remainder.
  203. /// </summary>
  204. /// <param name="request">The request to send to the server.</param>
  205. /// <param name="options">The options for the call.</param>
  206. /// <returns>The call object.</returns>
  207. public virtual grpc::AsyncUnaryCall<global::Math.DivReply> DivAsync(global::Math.DivArgs request, grpc::CallOptions options)
  208. {
  209. return CallInvoker.AsyncUnaryCall(__Method_Div, null, options, request);
  210. }
  211. /// <summary>
  212. /// DivMany accepts an arbitrary number of division args from the client stream
  213. /// and sends back the results in the reply stream. The stream continues until
  214. /// the client closes its end; the server does the same after sending all the
  215. /// replies. The stream ends immediately if either end aborts.
  216. /// </summary>
  217. /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
  218. /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
  219. /// <param name="cancellationToken">An optional token for canceling the call.</param>
  220. /// <returns>The call object.</returns>
  221. public virtual grpc::AsyncDuplexStreamingCall<global::Math.DivArgs, global::Math.DivReply> DivMany(grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
  222. {
  223. return DivMany(new grpc::CallOptions(headers, deadline, cancellationToken));
  224. }
  225. /// <summary>
  226. /// DivMany accepts an arbitrary number of division args from the client stream
  227. /// and sends back the results in the reply stream. The stream continues until
  228. /// the client closes its end; the server does the same after sending all the
  229. /// replies. The stream ends immediately if either end aborts.
  230. /// </summary>
  231. /// <param name="options">The options for the call.</param>
  232. /// <returns>The call object.</returns>
  233. public virtual grpc::AsyncDuplexStreamingCall<global::Math.DivArgs, global::Math.DivReply> DivMany(grpc::CallOptions options)
  234. {
  235. return CallInvoker.AsyncDuplexStreamingCall(__Method_DivMany, null, options);
  236. }
  237. /// <summary>
  238. /// Fib generates numbers in the Fibonacci sequence. If FibArgs.limit > 0, Fib
  239. /// generates up to limit numbers; otherwise it continues until the call is
  240. /// canceled. Unlike Fib above, Fib has no final FibReply.
  241. /// </summary>
  242. /// <param name="request">The request to send to the server.</param>
  243. /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
  244. /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
  245. /// <param name="cancellationToken">An optional token for canceling the call.</param>
  246. /// <returns>The call object.</returns>
  247. public virtual grpc::AsyncServerStreamingCall<global::Math.Num> Fib(global::Math.FibArgs request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
  248. {
  249. return Fib(request, new grpc::CallOptions(headers, deadline, cancellationToken));
  250. }
  251. /// <summary>
  252. /// Fib generates numbers in the Fibonacci sequence. If FibArgs.limit > 0, Fib
  253. /// generates up to limit numbers; otherwise it continues until the call is
  254. /// canceled. Unlike Fib above, Fib has no final FibReply.
  255. /// </summary>
  256. /// <param name="request">The request to send to the server.</param>
  257. /// <param name="options">The options for the call.</param>
  258. /// <returns>The call object.</returns>
  259. public virtual grpc::AsyncServerStreamingCall<global::Math.Num> Fib(global::Math.FibArgs request, grpc::CallOptions options)
  260. {
  261. return CallInvoker.AsyncServerStreamingCall(__Method_Fib, null, options, request);
  262. }
  263. /// <summary>
  264. /// Sum sums a stream of numbers, returning the final result once the stream
  265. /// is closed.
  266. /// </summary>
  267. /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
  268. /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
  269. /// <param name="cancellationToken">An optional token for canceling the call.</param>
  270. /// <returns>The call object.</returns>
  271. public virtual grpc::AsyncClientStreamingCall<global::Math.Num, global::Math.Num> Sum(grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
  272. {
  273. return Sum(new grpc::CallOptions(headers, deadline, cancellationToken));
  274. }
  275. /// <summary>
  276. /// Sum sums a stream of numbers, returning the final result once the stream
  277. /// is closed.
  278. /// </summary>
  279. /// <param name="options">The options for the call.</param>
  280. /// <returns>The call object.</returns>
  281. public virtual grpc::AsyncClientStreamingCall<global::Math.Num, global::Math.Num> Sum(grpc::CallOptions options)
  282. {
  283. return CallInvoker.AsyncClientStreamingCall(__Method_Sum, null, options);
  284. }
  285. /// <summary>Creates a new instance of client from given <c>ClientBaseConfiguration</c>.</summary>
  286. protected override MathClient NewInstance(ClientBaseConfiguration configuration)
  287. {
  288. return new MathClient(configuration);
  289. }
  290. }
  291. /// <summary>Creates service definition that can be registered with a server</summary>
  292. /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
  293. public static grpc::ServerServiceDefinition BindService(MathBase serviceImpl)
  294. {
  295. return grpc::ServerServiceDefinition.CreateBuilder()
  296. .AddMethod(__Method_Div, serviceImpl.Div)
  297. .AddMethod(__Method_DivMany, serviceImpl.DivMany)
  298. .AddMethod(__Method_Fib, serviceImpl.Fib)
  299. .AddMethod(__Method_Sum, serviceImpl.Sum).Build();
  300. }
  301. /// <summary>Register service method with a service binder with or without implementation. Useful when customizing the service binding logic.
  302. /// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary>
  303. /// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param>
  304. /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
  305. public static void BindService(grpc::ServiceBinderBase serviceBinder, MathBase serviceImpl)
  306. {
  307. serviceBinder.AddMethod(__Method_Div, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Math.DivArgs, global::Math.DivReply>(serviceImpl.Div));
  308. serviceBinder.AddMethod(__Method_DivMany, serviceImpl == null ? null : new grpc::DuplexStreamingServerMethod<global::Math.DivArgs, global::Math.DivReply>(serviceImpl.DivMany));
  309. serviceBinder.AddMethod(__Method_Fib, serviceImpl == null ? null : new grpc::ServerStreamingServerMethod<global::Math.FibArgs, global::Math.Num>(serviceImpl.Fib));
  310. serviceBinder.AddMethod(__Method_Sum, serviceImpl == null ? null : new grpc::ClientStreamingServerMethod<global::Math.Num, global::Math.Num>(serviceImpl.Sum));
  311. }
  312. }
  313. }
  314. #endregion