Grpc.Core.DeserializationContext.html 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <!DOCTYPE html>
  2. <!--[if IE]><![endif]-->
  3. <html>
  4. <head>
  5. <meta charset="utf-8">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  7. <title>Class DeserializationContext
  8. | gRPC for .NET </title>
  9. <meta name="viewport" content="width=device-width">
  10. <meta name="title" content="Class DeserializationContext
  11. | gRPC for .NET ">
  12. <meta name="generator" content="docfx 2.36.0.0">
  13. <link rel="shortcut icon" href="../favicon.ico">
  14. <link rel="stylesheet" href="../styles/docfx.vendor.css">
  15. <link rel="stylesheet" href="../styles/docfx.css">
  16. <link rel="stylesheet" href="../styles/main.css">
  17. <meta property="docfx:navrel" content="../toc.html">
  18. <meta property="docfx:tocrel" content="toc.html">
  19. <meta property="docfx:rel" content="../">
  20. </head>
  21. <body data-spy="scroll" data-target="#affix" data-offset="120">
  22. <div id="wrapper">
  23. <header>
  24. <nav id="autocollapse" class="navbar navbar-inverse ng-scope" role="navigation">
  25. <div class="container">
  26. <div class="navbar-header">
  27. <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
  28. <span class="sr-only">Toggle navigation</span>
  29. <span class="icon-bar"></span>
  30. <span class="icon-bar"></span>
  31. <span class="icon-bar"></span>
  32. </button>
  33. <a class="navbar-brand" href="../index.html">
  34. <img id="logo" class="svg" src="../logo.svg" alt="">
  35. </a>
  36. </div>
  37. <div class="collapse navbar-collapse" id="navbar">
  38. <form class="navbar-form navbar-right" role="search" id="search">
  39. <div class="form-group">
  40. <input type="text" class="form-control" id="search-query" placeholder="Search" autocomplete="off">
  41. </div>
  42. </form>
  43. </div>
  44. </div>
  45. </nav>
  46. <div class="subnav navbar navbar-default">
  47. <div class="container hide-when-search" id="breadcrumb">
  48. <ul class="breadcrumb">
  49. <li></li>
  50. </ul>
  51. </div>
  52. </div>
  53. </header>
  54. <div class="container body-content">
  55. <div id="search-results">
  56. <div class="search-list"></div>
  57. <div class="sr-items">
  58. <p><i class="glyphicon glyphicon-refresh index-loading"></i></p>
  59. </div>
  60. <ul id="pagination"></ul>
  61. </div>
  62. </div>
  63. <div role="main" class="container body-content hide-when-search">
  64. <div class="sidenav hide-when-search">
  65. <a class="btn toc-toggle collapse" data-toggle="collapse" href="#sidetoggle" aria-expanded="false" aria-controls="sidetoggle">Show / Hide Table of Contents</a>
  66. <div class="sidetoggle collapse" id="sidetoggle">
  67. <div id="sidetoc"></div>
  68. </div>
  69. </div>
  70. <div class="article row grid-right">
  71. <div class="col-md-10">
  72. <article class="content wrap" id="_content" data-uid="Grpc.Core.DeserializationContext">
  73. <h1 id="Grpc_Core_DeserializationContext" data-uid="Grpc.Core.DeserializationContext" class="text-break">Class DeserializationContext
  74. </h1>
  75. <div class="markdown level0 summary"><p>Provides access to the payload being deserialized when deserializing messages.</p>
  76. </div>
  77. <div class="markdown level0 conceptual"></div>
  78. <div class="inheritance">
  79. <h5>Inheritance</h5>
  80. <div class="level0"><span class="xref">System.Object</span></div>
  81. <div class="level1"><span class="xref">DeserializationContext</span></div>
  82. </div>
  83. <h6><strong>Namespace</strong>: <a class="xref" href="Grpc.Core.html">Grpc.Core</a></h6>
  84. <h6><strong>Assembly</strong>: Grpc.Core.Api.dll</h6>
  85. <h5 id="Grpc_Core_DeserializationContext_syntax">Syntax</h5>
  86. <div class="codewrapper">
  87. <pre><code class="lang-csharp hljs">public abstract class DeserializationContext : object</code></pre>
  88. </div>
  89. <h3 id="properties">Properties
  90. </h3>
  91. <a id="Grpc_Core_DeserializationContext_PayloadLength_" data-uid="Grpc.Core.DeserializationContext.PayloadLength*"></a>
  92. <h4 id="Grpc_Core_DeserializationContext_PayloadLength" data-uid="Grpc.Core.DeserializationContext.PayloadLength">PayloadLength</h4>
  93. <div class="markdown level1 summary"><p>Get the total length of the payload in bytes.</p>
  94. </div>
  95. <div class="markdown level1 conceptual"></div>
  96. <h5 class="decalaration">Declaration</h5>
  97. <div class="codewrapper">
  98. <pre><code class="lang-csharp hljs">public abstract int PayloadLength { get; }</code></pre>
  99. </div>
  100. <h5 class="propertyValue">Property Value</h5>
  101. <table class="table table-bordered table-striped table-condensed">
  102. <thead>
  103. <tr>
  104. <th>Type</th>
  105. <th>Description</th>
  106. </tr>
  107. </thead>
  108. <tbody>
  109. <tr>
  110. <td><span class="xref">System.Int32</span></td>
  111. <td></td>
  112. </tr>
  113. </tbody>
  114. </table>
  115. <h3 id="methods">Methods
  116. </h3>
  117. <a id="Grpc_Core_DeserializationContext_PayloadAsNewBuffer_" data-uid="Grpc.Core.DeserializationContext.PayloadAsNewBuffer*"></a>
  118. <h4 id="Grpc_Core_DeserializationContext_PayloadAsNewBuffer" data-uid="Grpc.Core.DeserializationContext.PayloadAsNewBuffer">PayloadAsNewBuffer()</h4>
  119. <div class="markdown level1 summary"><p>Gets the entire payload as a newly allocated byte array.
  120. Once the byte array is returned, the byte array becomes owned by the caller and won&apos;t be ever accessed or reused by gRPC again.
  121. NOTE: Obtaining the buffer as a newly allocated byte array is the simplest way of accessing the payload,
  122. but it can have important consequences in high-performance scenarios.
  123. In particular, using this method usually requires copying of the entire buffer one extra time.
  124. Also, allocating a new buffer each time can put excessive pressure on GC, especially if
  125. the payload is more than 86700 bytes large (which means the newly allocated buffer will be placed in LOH,
  126. and LOH object can only be garbage collected via a full (&quot;stop the world&quot;) GC run).
  127. NOTE: Deserializers are expected not to call this method (or other payload accessor methods) more than once per received message
  128. (as there is no practical reason for doing so) and <code>DeserializationContext</code> implementations are free to assume so.</p>
  129. </div>
  130. <div class="markdown level1 conceptual"></div>
  131. <h5 class="decalaration">Declaration</h5>
  132. <div class="codewrapper">
  133. <pre><code class="lang-csharp hljs">public virtual byte[] PayloadAsNewBuffer()</code></pre>
  134. </div>
  135. <h5 class="returns">Returns</h5>
  136. <table class="table table-bordered table-striped table-condensed">
  137. <thead>
  138. <tr>
  139. <th>Type</th>
  140. <th>Description</th>
  141. </tr>
  142. </thead>
  143. <tbody>
  144. <tr>
  145. <td><span class="xref">System.Byte</span>[]</td>
  146. <td><p>byte array containing the entire payload.</p>
  147. </td>
  148. </tr>
  149. </tbody>
  150. </table>
  151. <a id="Grpc_Core_DeserializationContext_PayloadAsReadOnlySequence_" data-uid="Grpc.Core.DeserializationContext.PayloadAsReadOnlySequence*"></a>
  152. <h4 id="Grpc_Core_DeserializationContext_PayloadAsReadOnlySequence" data-uid="Grpc.Core.DeserializationContext.PayloadAsReadOnlySequence">PayloadAsReadOnlySequence()</h4>
  153. <div class="markdown level1 summary"><p>Gets the entire payload as a ReadOnlySequence.
  154. The ReadOnlySequence is only valid for the duration of the deserializer routine and the caller must not access it after the deserializer returns.
  155. Using the read only sequence is the most efficient way to access the message payload. Where possible it allows directly
  156. accessing the received payload without needing to perform any buffer copying or buffer allocations.
  157. NOTE: When using this method, it is recommended to use C# 7.2 compiler to make it more useful (using Span type directly from your code requires C# 7.2).&quot;
  158. NOTE: Deserializers are expected not to call this method (or other payload accessor methods) more than once per received message
  159. (as there is no practical reason for doing so) and <code>DeserializationContext</code> implementations are free to assume so.</p>
  160. </div>
  161. <div class="markdown level1 conceptual"></div>
  162. <h5 class="decalaration">Declaration</h5>
  163. <div class="codewrapper">
  164. <pre><code class="lang-csharp hljs">public virtual System.Buffers.ReadOnlySequence&lt;byte&gt; PayloadAsReadOnlySequence()</code></pre>
  165. </div>
  166. <h5 class="returns">Returns</h5>
  167. <table class="table table-bordered table-striped table-condensed">
  168. <thead>
  169. <tr>
  170. <th>Type</th>
  171. <th>Description</th>
  172. </tr>
  173. </thead>
  174. <tbody>
  175. <tr>
  176. <td><span class="xref">System.Buffers.ReadOnlySequence</span>&lt;<span class="xref">System.Byte</span>&gt;</td>
  177. <td><p>read only sequence containing the entire payload.</p>
  178. </td>
  179. </tr>
  180. </tbody>
  181. </table>
  182. </article>
  183. </div>
  184. <div class="hidden-sm col-md-2" role="complementary">
  185. <div class="sideaffix">
  186. <nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
  187. <!-- <p><a class="back-to-top" href="#top">Back to top</a><p> -->
  188. </nav>
  189. </div>
  190. </div>
  191. </div>
  192. </div>
  193. <footer>
  194. <div class="grad-bottom"></div>
  195. <div class="footer">
  196. <div class="container">
  197. <span class="pull-right">
  198. <a href="#top">Back to top</a>
  199. </span>
  200. <span>Generated by <strong>DocFX</strong></span>
  201. </div>
  202. </div>
  203. </footer>
  204. </div>
  205. <script type="text/javascript" src="../styles/docfx.vendor.js"></script>
  206. <script type="text/javascript" src="../styles/docfx.js"></script>
  207. <script type="text/javascript" src="../styles/main.js"></script>
  208. </body>
  209. </html>