Microsoft.Extensions.DependencyInjection.GrpcClientServiceExtensions.html 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  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 GrpcClientServiceExtensions
  8. | gRPC for .NET </title>
  9. <meta name="viewport" content="width=device-width">
  10. <meta name="title" content="Class GrpcClientServiceExtensions
  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="Microsoft.Extensions.DependencyInjection.GrpcClientServiceExtensions">
  73. <h1 id="Microsoft_Extensions_DependencyInjection_GrpcClientServiceExtensions" data-uid="Microsoft.Extensions.DependencyInjection.GrpcClientServiceExtensions" class="text-break">Class GrpcClientServiceExtensions
  74. </h1>
  75. <div class="markdown level0 summary"><p>Extensions methods to configure an <see cref="!:IServiceCollection"></see> for <see cref="!:IHttpClientFactory"></see> with gRPC.</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">GrpcClientServiceExtensions</span></div>
  82. </div>
  83. <h6><strong>Namespace</strong>: <a class="xref" href="Microsoft.Extensions.DependencyInjection.html">Microsoft.Extensions.DependencyInjection</a></h6>
  84. <h6><strong>Assembly</strong>: Grpc.Net.ClientFactory.dll</h6>
  85. <h5 id="Microsoft_Extensions_DependencyInjection_GrpcClientServiceExtensions_syntax">Syntax</h5>
  86. <div class="codewrapper">
  87. <pre><code class="lang-csharp hljs">public static class GrpcClientServiceExtensions : object</code></pre>
  88. </div>
  89. <h3 id="methods">Methods
  90. </h3>
  91. <a id="Microsoft_Extensions_DependencyInjection_GrpcClientServiceExtensions_AddGrpcClient_" data-uid="Microsoft.Extensions.DependencyInjection.GrpcClientServiceExtensions.AddGrpcClient*"></a>
  92. <h4 id="Microsoft_Extensions_DependencyInjection_GrpcClientServiceExtensions_AddGrpcClient__1_IServiceCollection_" data-uid="Microsoft.Extensions.DependencyInjection.GrpcClientServiceExtensions.AddGrpcClient``1(IServiceCollection)">AddGrpcClient&lt;TClient&gt;(IServiceCollection)</h4>
  93. <div class="markdown level1 summary"><p>Adds the <see cref="!:IHttpClientFactory"></see> and related services to the <see cref="!:IServiceCollection"></see> and configures
  94. a binding between the <code data-dev-comment-type="typeparamref" class="typeparamref">TClient</code> type and a named <see cref="!:HttpClient"></see>. The client name
  95. will be set to the type name of <code data-dev-comment-type="typeparamref" class="typeparamref">TClient</code>.</p>
  96. </div>
  97. <div class="markdown level1 conceptual"></div>
  98. <h5 class="decalaration">Declaration</h5>
  99. <div class="codewrapper">
  100. <pre><code class="lang-csharp hljs">public static IHttpClientBuilder AddGrpcClient&lt;TClient&gt;(this IServiceCollection services)
  101. where TClient : ClientBase</code></pre>
  102. </div>
  103. <h5 class="parameters">Parameters</h5>
  104. <table class="table table-bordered table-striped table-condensed">
  105. <thead>
  106. <tr>
  107. <th>Type</th>
  108. <th>Name</th>
  109. <th>Description</th>
  110. </tr>
  111. </thead>
  112. <tbody>
  113. <tr>
  114. <td><span class="xref">IServiceCollection</span></td>
  115. <td><span class="parametername">services</span></td>
  116. <td><p>The <see cref="!:IServiceCollection"></see>.</p>
  117. </td>
  118. </tr>
  119. </tbody>
  120. </table>
  121. <h5 class="returns">Returns</h5>
  122. <table class="table table-bordered table-striped table-condensed">
  123. <thead>
  124. <tr>
  125. <th>Type</th>
  126. <th>Description</th>
  127. </tr>
  128. </thead>
  129. <tbody>
  130. <tr>
  131. <td><span class="xref">IHttpClientBuilder</span></td>
  132. <td><p>An <see cref="!:IHttpClientBuilder"></see> that can be used to configure the client.</p>
  133. </td>
  134. </tr>
  135. </tbody>
  136. </table>
  137. <h5 class="typeParameters">Type Parameters</h5>
  138. <table class="table table-bordered table-striped table-condensed">
  139. <thead>
  140. <tr>
  141. <th>Name</th>
  142. <th>Description</th>
  143. </tr>
  144. </thead>
  145. <tbody>
  146. <tr>
  147. <td><span class="parametername">TClient</span></td>
  148. <td><p>The type of the gRPC client. The type specified will be registered in the service collection as
  149. a transient service.</p>
  150. </td>
  151. </tr>
  152. </tbody>
  153. </table>
  154. <h5 id="Microsoft_Extensions_DependencyInjection_GrpcClientServiceExtensions_AddGrpcClient__1_IServiceCollection__remarks">Remarks</h5>
  155. <div class="markdown level1 remarks"><p>
  156. <see cref="!:HttpClient"></see> instances that apply the provided configuration can be retrieved using
  157. <see cref="!:IHttpClientFactory.CreateClient(string)"></see> and providing the matching name.
  158. </p>
  159. <p>
  160. <code data-dev-comment-type="typeparamref" class="typeparamref">TClient</code> instances constructed with the appropriate <see cref="!:HttpClient"></see>
  161. can be retrieved from <see cref="!:IServiceProvider.GetService(Type)"></see> (and related methods) by providing
  162. <code data-dev-comment-type="typeparamref" class="typeparamref">TClient</code> as the service type.
  163. </p>
  164. </div>
  165. <a id="Microsoft_Extensions_DependencyInjection_GrpcClientServiceExtensions_AddGrpcClient_" data-uid="Microsoft.Extensions.DependencyInjection.GrpcClientServiceExtensions.AddGrpcClient*"></a>
  166. <h4 id="Microsoft_Extensions_DependencyInjection_GrpcClientServiceExtensions_AddGrpcClient__1_IServiceCollection_Action_Grpc_Net_ClientFactory_GrpcClientFactoryOptions__" data-uid="Microsoft.Extensions.DependencyInjection.GrpcClientServiceExtensions.AddGrpcClient``1(IServiceCollection,Action{Grpc.Net.ClientFactory.GrpcClientFactoryOptions})">AddGrpcClient&lt;TClient&gt;(IServiceCollection, Action&lt;GrpcClientFactoryOptions&gt;)</h4>
  167. <div class="markdown level1 summary"><p>Adds the <see cref="!:IHttpClientFactory"></see> and related services to the <see cref="!:IServiceCollection"></see> and configures
  168. a binding between the <code data-dev-comment-type="typeparamref" class="typeparamref">TClient</code> type and a named <see cref="!:HttpClient"></see>. The client name
  169. will be set to the type name of <code data-dev-comment-type="typeparamref" class="typeparamref">TClient</code>.</p>
  170. </div>
  171. <div class="markdown level1 conceptual"></div>
  172. <h5 class="decalaration">Declaration</h5>
  173. <div class="codewrapper">
  174. <pre><code class="lang-csharp hljs">public static IHttpClientBuilder AddGrpcClient&lt;TClient&gt;(this IServiceCollection services, Action&lt;GrpcClientFactoryOptions&gt; configureClient)
  175. where TClient : ClientBase</code></pre>
  176. </div>
  177. <h5 class="parameters">Parameters</h5>
  178. <table class="table table-bordered table-striped table-condensed">
  179. <thead>
  180. <tr>
  181. <th>Type</th>
  182. <th>Name</th>
  183. <th>Description</th>
  184. </tr>
  185. </thead>
  186. <tbody>
  187. <tr>
  188. <td><span class="xref">IServiceCollection</span></td>
  189. <td><span class="parametername">services</span></td>
  190. <td><p>The <see cref="!:IServiceCollection"></see>.</p>
  191. </td>
  192. </tr>
  193. <tr>
  194. <td><span class="xref">Action</span>&lt;<a class="xref" href="Grpc.Net.ClientFactory.GrpcClientFactoryOptions.html">GrpcClientFactoryOptions</a>&gt;</td>
  195. <td><span class="parametername">configureClient</span></td>
  196. <td><p>A delegate that is used to configure the gRPC client.</p>
  197. </td>
  198. </tr>
  199. </tbody>
  200. </table>
  201. <h5 class="returns">Returns</h5>
  202. <table class="table table-bordered table-striped table-condensed">
  203. <thead>
  204. <tr>
  205. <th>Type</th>
  206. <th>Description</th>
  207. </tr>
  208. </thead>
  209. <tbody>
  210. <tr>
  211. <td><span class="xref">IHttpClientBuilder</span></td>
  212. <td><p>An <see cref="!:IHttpClientBuilder"></see> that can be used to configure the client.</p>
  213. </td>
  214. </tr>
  215. </tbody>
  216. </table>
  217. <h5 class="typeParameters">Type Parameters</h5>
  218. <table class="table table-bordered table-striped table-condensed">
  219. <thead>
  220. <tr>
  221. <th>Name</th>
  222. <th>Description</th>
  223. </tr>
  224. </thead>
  225. <tbody>
  226. <tr>
  227. <td><span class="parametername">TClient</span></td>
  228. <td><p>The type of the gRPC client. The type specified will be registered in the service collection as
  229. a transient service.</p>
  230. </td>
  231. </tr>
  232. </tbody>
  233. </table>
  234. <h5 id="Microsoft_Extensions_DependencyInjection_GrpcClientServiceExtensions_AddGrpcClient__1_IServiceCollection_Action_Grpc_Net_ClientFactory_GrpcClientFactoryOptions___remarks">Remarks</h5>
  235. <div class="markdown level1 remarks"><p>
  236. <see cref="!:HttpClient"></see> instances that apply the provided configuration can be retrieved using
  237. <see cref="!:IHttpClientFactory.CreateClient(string)"></see> and providing the matching name.
  238. </p>
  239. <p>
  240. <code data-dev-comment-type="typeparamref" class="typeparamref">TClient</code> instances constructed with the appropriate <see cref="!:HttpClient"></see>
  241. can be retrieved from <see cref="!:IServiceProvider.GetService(Type)"></see> (and related methods) by providing
  242. <code data-dev-comment-type="typeparamref" class="typeparamref">TClient</code> as the service type.
  243. </p>
  244. </div>
  245. <a id="Microsoft_Extensions_DependencyInjection_GrpcClientServiceExtensions_AddGrpcClient_" data-uid="Microsoft.Extensions.DependencyInjection.GrpcClientServiceExtensions.AddGrpcClient*"></a>
  246. <h4 id="Microsoft_Extensions_DependencyInjection_GrpcClientServiceExtensions_AddGrpcClient__1_IServiceCollection_Action_IServiceProvider_Grpc_Net_ClientFactory_GrpcClientFactoryOptions__" data-uid="Microsoft.Extensions.DependencyInjection.GrpcClientServiceExtensions.AddGrpcClient``1(IServiceCollection,Action{IServiceProvider,Grpc.Net.ClientFactory.GrpcClientFactoryOptions})">AddGrpcClient&lt;TClient&gt;(IServiceCollection, Action&lt;IServiceProvider, GrpcClientFactoryOptions&gt;)</h4>
  247. <div class="markdown level1 summary"><p>Adds the <see cref="!:IHttpClientFactory"></see> and related services to the <see cref="!:IServiceCollection"></see> and configures
  248. a binding between the <code data-dev-comment-type="typeparamref" class="typeparamref">TClient</code> type and a named <see cref="!:HttpClient"></see>. The client name
  249. will be set to the type name of <code data-dev-comment-type="typeparamref" class="typeparamref">TClient</code>.</p>
  250. </div>
  251. <div class="markdown level1 conceptual"></div>
  252. <h5 class="decalaration">Declaration</h5>
  253. <div class="codewrapper">
  254. <pre><code class="lang-csharp hljs">public static IHttpClientBuilder AddGrpcClient&lt;TClient&gt;(this IServiceCollection services, Action&lt;IServiceProvider, GrpcClientFactoryOptions&gt; configureClient)
  255. where TClient : ClientBase</code></pre>
  256. </div>
  257. <h5 class="parameters">Parameters</h5>
  258. <table class="table table-bordered table-striped table-condensed">
  259. <thead>
  260. <tr>
  261. <th>Type</th>
  262. <th>Name</th>
  263. <th>Description</th>
  264. </tr>
  265. </thead>
  266. <tbody>
  267. <tr>
  268. <td><span class="xref">IServiceCollection</span></td>
  269. <td><span class="parametername">services</span></td>
  270. <td><p>The <see cref="!:IServiceCollection"></see>.</p>
  271. </td>
  272. </tr>
  273. <tr>
  274. <td><span class="xref">Action</span>&lt;<span class="xref">IServiceProvider</span>, <a class="xref" href="Grpc.Net.ClientFactory.GrpcClientFactoryOptions.html">GrpcClientFactoryOptions</a>&gt;</td>
  275. <td><span class="parametername">configureClient</span></td>
  276. <td><p>A delegate that is used to configure the gRPC client.</p>
  277. </td>
  278. </tr>
  279. </tbody>
  280. </table>
  281. <h5 class="returns">Returns</h5>
  282. <table class="table table-bordered table-striped table-condensed">
  283. <thead>
  284. <tr>
  285. <th>Type</th>
  286. <th>Description</th>
  287. </tr>
  288. </thead>
  289. <tbody>
  290. <tr>
  291. <td><span class="xref">IHttpClientBuilder</span></td>
  292. <td><p>An <see cref="!:IHttpClientBuilder"></see> that can be used to configure the client.</p>
  293. </td>
  294. </tr>
  295. </tbody>
  296. </table>
  297. <h5 class="typeParameters">Type Parameters</h5>
  298. <table class="table table-bordered table-striped table-condensed">
  299. <thead>
  300. <tr>
  301. <th>Name</th>
  302. <th>Description</th>
  303. </tr>
  304. </thead>
  305. <tbody>
  306. <tr>
  307. <td><span class="parametername">TClient</span></td>
  308. <td><p>The type of the gRPC client. The type specified will be registered in the service collection as
  309. a transient service.</p>
  310. </td>
  311. </tr>
  312. </tbody>
  313. </table>
  314. <h5 id="Microsoft_Extensions_DependencyInjection_GrpcClientServiceExtensions_AddGrpcClient__1_IServiceCollection_Action_IServiceProvider_Grpc_Net_ClientFactory_GrpcClientFactoryOptions___remarks">Remarks</h5>
  315. <div class="markdown level1 remarks"><p>
  316. <see cref="!:HttpClient"></see> instances that apply the provided configuration can be retrieved using
  317. <see cref="!:IHttpClientFactory.CreateClient(string)"></see> and providing the matching name.
  318. </p>
  319. <p>
  320. <code data-dev-comment-type="typeparamref" class="typeparamref">TClient</code> instances constructed with the appropriate <see cref="!:HttpClient"></see>
  321. can be retrieved from <see cref="!:IServiceProvider.GetService(Type)"></see> (and related methods) by providing
  322. <code data-dev-comment-type="typeparamref" class="typeparamref">TClient</code> as the service type.
  323. </p>
  324. <p>
  325. The <see cref="!:IServiceProvider"></see> argument provided to <code data-dev-comment-type="paramref" class="paramref">configureClient</code> will be
  326. a reference to a scoped service provider that shares the lifetime of the handler being constructed.
  327. </p>
  328. </div>
  329. <a id="Microsoft_Extensions_DependencyInjection_GrpcClientServiceExtensions_AddGrpcClient_" data-uid="Microsoft.Extensions.DependencyInjection.GrpcClientServiceExtensions.AddGrpcClient*"></a>
  330. <h4 id="Microsoft_Extensions_DependencyInjection_GrpcClientServiceExtensions_AddGrpcClient__1_IServiceCollection_System_String_" data-uid="Microsoft.Extensions.DependencyInjection.GrpcClientServiceExtensions.AddGrpcClient``1(IServiceCollection,System.String)">AddGrpcClient&lt;TClient&gt;(IServiceCollection, String)</h4>
  331. <div class="markdown level1 summary"><p>Adds the <see cref="!:IHttpClientFactory"></see> and related services to the <see cref="!:IServiceCollection"></see> and configures
  332. a binding between the <code data-dev-comment-type="typeparamref" class="typeparamref">TClient</code> type and a named <see cref="!:HttpClient"></see>.</p>
  333. </div>
  334. <div class="markdown level1 conceptual"></div>
  335. <h5 class="decalaration">Declaration</h5>
  336. <div class="codewrapper">
  337. <pre><code class="lang-csharp hljs">public static IHttpClientBuilder AddGrpcClient&lt;TClient&gt;(this IServiceCollection services, string name)
  338. where TClient : ClientBase</code></pre>
  339. </div>
  340. <h5 class="parameters">Parameters</h5>
  341. <table class="table table-bordered table-striped table-condensed">
  342. <thead>
  343. <tr>
  344. <th>Type</th>
  345. <th>Name</th>
  346. <th>Description</th>
  347. </tr>
  348. </thead>
  349. <tbody>
  350. <tr>
  351. <td><span class="xref">IServiceCollection</span></td>
  352. <td><span class="parametername">services</span></td>
  353. <td><p>The <see cref="!:IServiceCollection"></see>.</p>
  354. </td>
  355. </tr>
  356. <tr>
  357. <td><span class="xref">System.String</span></td>
  358. <td><span class="parametername">name</span></td>
  359. <td><p>The logical name of the <see cref="!:HttpClient"></see> to configure.</p>
  360. </td>
  361. </tr>
  362. </tbody>
  363. </table>
  364. <h5 class="returns">Returns</h5>
  365. <table class="table table-bordered table-striped table-condensed">
  366. <thead>
  367. <tr>
  368. <th>Type</th>
  369. <th>Description</th>
  370. </tr>
  371. </thead>
  372. <tbody>
  373. <tr>
  374. <td><span class="xref">IHttpClientBuilder</span></td>
  375. <td><p>An <see cref="!:IHttpClientBuilder"></see> that can be used to configure the client.</p>
  376. </td>
  377. </tr>
  378. </tbody>
  379. </table>
  380. <h5 class="typeParameters">Type Parameters</h5>
  381. <table class="table table-bordered table-striped table-condensed">
  382. <thead>
  383. <tr>
  384. <th>Name</th>
  385. <th>Description</th>
  386. </tr>
  387. </thead>
  388. <tbody>
  389. <tr>
  390. <td><span class="parametername">TClient</span></td>
  391. <td><p>The type of the gRPC client. The type specified will be registered in the service collection as
  392. a transient service.</p>
  393. </td>
  394. </tr>
  395. </tbody>
  396. </table>
  397. <h5 id="Microsoft_Extensions_DependencyInjection_GrpcClientServiceExtensions_AddGrpcClient__1_IServiceCollection_System_String__remarks">Remarks</h5>
  398. <div class="markdown level1 remarks"><p>
  399. <see cref="!:HttpClient"></see> instances that apply the provided configuration can be retrieved using
  400. <see cref="!:IHttpClientFactory.CreateClient(string)"></see> and providing the matching name.
  401. </p>
  402. <p>
  403. <code data-dev-comment-type="typeparamref" class="typeparamref">TClient</code> instances constructed with the appropriate <see cref="!:HttpClient"></see>
  404. can be retrieved from <see cref="!:IServiceProvider.GetService(Type)"></see> (and related methods) by providing
  405. <code data-dev-comment-type="typeparamref" class="typeparamref">TClient</code> as the service type.
  406. </p>
  407. </div>
  408. <a id="Microsoft_Extensions_DependencyInjection_GrpcClientServiceExtensions_AddGrpcClient_" data-uid="Microsoft.Extensions.DependencyInjection.GrpcClientServiceExtensions.AddGrpcClient*"></a>
  409. <h4 id="Microsoft_Extensions_DependencyInjection_GrpcClientServiceExtensions_AddGrpcClient__1_IServiceCollection_System_String_Action_Grpc_Net_ClientFactory_GrpcClientFactoryOptions__" data-uid="Microsoft.Extensions.DependencyInjection.GrpcClientServiceExtensions.AddGrpcClient``1(IServiceCollection,System.String,Action{Grpc.Net.ClientFactory.GrpcClientFactoryOptions})">AddGrpcClient&lt;TClient&gt;(IServiceCollection, String, Action&lt;GrpcClientFactoryOptions&gt;)</h4>
  410. <div class="markdown level1 summary"><p>Adds the <see cref="!:IHttpClientFactory"></see> and related services to the <see cref="!:IServiceCollection"></see> and configures
  411. a binding between the <code data-dev-comment-type="typeparamref" class="typeparamref">TClient</code> type and a named <see cref="!:HttpClient"></see>.</p>
  412. </div>
  413. <div class="markdown level1 conceptual"></div>
  414. <h5 class="decalaration">Declaration</h5>
  415. <div class="codewrapper">
  416. <pre><code class="lang-csharp hljs">public static IHttpClientBuilder AddGrpcClient&lt;TClient&gt;(this IServiceCollection services, string name, Action&lt;GrpcClientFactoryOptions&gt; configureClient)
  417. where TClient : ClientBase</code></pre>
  418. </div>
  419. <h5 class="parameters">Parameters</h5>
  420. <table class="table table-bordered table-striped table-condensed">
  421. <thead>
  422. <tr>
  423. <th>Type</th>
  424. <th>Name</th>
  425. <th>Description</th>
  426. </tr>
  427. </thead>
  428. <tbody>
  429. <tr>
  430. <td><span class="xref">IServiceCollection</span></td>
  431. <td><span class="parametername">services</span></td>
  432. <td><p>The <see cref="!:IServiceCollection"></see>.</p>
  433. </td>
  434. </tr>
  435. <tr>
  436. <td><span class="xref">System.String</span></td>
  437. <td><span class="parametername">name</span></td>
  438. <td><p>The logical name of the <see cref="!:HttpClient"></see> to configure.</p>
  439. </td>
  440. </tr>
  441. <tr>
  442. <td><span class="xref">Action</span>&lt;<a class="xref" href="Grpc.Net.ClientFactory.GrpcClientFactoryOptions.html">GrpcClientFactoryOptions</a>&gt;</td>
  443. <td><span class="parametername">configureClient</span></td>
  444. <td><p>A delegate that is used to configure the gRPC client.</p>
  445. </td>
  446. </tr>
  447. </tbody>
  448. </table>
  449. <h5 class="returns">Returns</h5>
  450. <table class="table table-bordered table-striped table-condensed">
  451. <thead>
  452. <tr>
  453. <th>Type</th>
  454. <th>Description</th>
  455. </tr>
  456. </thead>
  457. <tbody>
  458. <tr>
  459. <td><span class="xref">IHttpClientBuilder</span></td>
  460. <td><p>An <see cref="!:IHttpClientBuilder"></see> that can be used to configure the client.</p>
  461. </td>
  462. </tr>
  463. </tbody>
  464. </table>
  465. <h5 class="typeParameters">Type Parameters</h5>
  466. <table class="table table-bordered table-striped table-condensed">
  467. <thead>
  468. <tr>
  469. <th>Name</th>
  470. <th>Description</th>
  471. </tr>
  472. </thead>
  473. <tbody>
  474. <tr>
  475. <td><span class="parametername">TClient</span></td>
  476. <td><p>The type of the gRPC client. The type specified will be registered in the service collection as
  477. a transient service.</p>
  478. </td>
  479. </tr>
  480. </tbody>
  481. </table>
  482. <h5 id="Microsoft_Extensions_DependencyInjection_GrpcClientServiceExtensions_AddGrpcClient__1_IServiceCollection_System_String_Action_Grpc_Net_ClientFactory_GrpcClientFactoryOptions___remarks">Remarks</h5>
  483. <div class="markdown level1 remarks"><p>
  484. <see cref="!:HttpClient"></see> instances that apply the provided configuration can be retrieved using
  485. <see cref="!:IHttpClientFactory.CreateClient(string)"></see> and providing the matching name.
  486. </p>
  487. <p>
  488. <code data-dev-comment-type="typeparamref" class="typeparamref">TClient</code> instances constructed with the appropriate <see cref="!:HttpClient"></see>
  489. can be retrieved from <see cref="!:IServiceProvider.GetService(Type)"></see> (and related methods) by providing
  490. <code data-dev-comment-type="typeparamref" class="typeparamref">TClient</code> as the service type.
  491. </p>
  492. </div>
  493. <a id="Microsoft_Extensions_DependencyInjection_GrpcClientServiceExtensions_AddGrpcClient_" data-uid="Microsoft.Extensions.DependencyInjection.GrpcClientServiceExtensions.AddGrpcClient*"></a>
  494. <h4 id="Microsoft_Extensions_DependencyInjection_GrpcClientServiceExtensions_AddGrpcClient__1_IServiceCollection_System_String_Action_IServiceProvider_Grpc_Net_ClientFactory_GrpcClientFactoryOptions__" data-uid="Microsoft.Extensions.DependencyInjection.GrpcClientServiceExtensions.AddGrpcClient``1(IServiceCollection,System.String,Action{IServiceProvider,Grpc.Net.ClientFactory.GrpcClientFactoryOptions})">AddGrpcClient&lt;TClient&gt;(IServiceCollection, String, Action&lt;IServiceProvider, GrpcClientFactoryOptions&gt;)</h4>
  495. <div class="markdown level1 summary"><p>Adds the <see cref="!:IHttpClientFactory"></see> and related services to the <see cref="!:IServiceCollection"></see> and configures
  496. a binding between the <code data-dev-comment-type="typeparamref" class="typeparamref">TClient</code> type and a named <see cref="!:HttpClient"></see>.</p>
  497. </div>
  498. <div class="markdown level1 conceptual"></div>
  499. <h5 class="decalaration">Declaration</h5>
  500. <div class="codewrapper">
  501. <pre><code class="lang-csharp hljs">public static IHttpClientBuilder AddGrpcClient&lt;TClient&gt;(this IServiceCollection services, string name, Action&lt;IServiceProvider, GrpcClientFactoryOptions&gt; configureClient)
  502. where TClient : ClientBase</code></pre>
  503. </div>
  504. <h5 class="parameters">Parameters</h5>
  505. <table class="table table-bordered table-striped table-condensed">
  506. <thead>
  507. <tr>
  508. <th>Type</th>
  509. <th>Name</th>
  510. <th>Description</th>
  511. </tr>
  512. </thead>
  513. <tbody>
  514. <tr>
  515. <td><span class="xref">IServiceCollection</span></td>
  516. <td><span class="parametername">services</span></td>
  517. <td><p>The <see cref="!:IServiceCollection"></see>.</p>
  518. </td>
  519. </tr>
  520. <tr>
  521. <td><span class="xref">System.String</span></td>
  522. <td><span class="parametername">name</span></td>
  523. <td><p>The logical name of the <see cref="!:HttpClient"></see> to configure.</p>
  524. </td>
  525. </tr>
  526. <tr>
  527. <td><span class="xref">Action</span>&lt;<span class="xref">IServiceProvider</span>, <a class="xref" href="Grpc.Net.ClientFactory.GrpcClientFactoryOptions.html">GrpcClientFactoryOptions</a>&gt;</td>
  528. <td><span class="parametername">configureClient</span></td>
  529. <td><p>A delegate that is used to configure the gRPC client.</p>
  530. </td>
  531. </tr>
  532. </tbody>
  533. </table>
  534. <h5 class="returns">Returns</h5>
  535. <table class="table table-bordered table-striped table-condensed">
  536. <thead>
  537. <tr>
  538. <th>Type</th>
  539. <th>Description</th>
  540. </tr>
  541. </thead>
  542. <tbody>
  543. <tr>
  544. <td><span class="xref">IHttpClientBuilder</span></td>
  545. <td><p>An <see cref="!:IHttpClientBuilder"></see> that can be used to configure the client.</p>
  546. </td>
  547. </tr>
  548. </tbody>
  549. </table>
  550. <h5 class="typeParameters">Type Parameters</h5>
  551. <table class="table table-bordered table-striped table-condensed">
  552. <thead>
  553. <tr>
  554. <th>Name</th>
  555. <th>Description</th>
  556. </tr>
  557. </thead>
  558. <tbody>
  559. <tr>
  560. <td><span class="parametername">TClient</span></td>
  561. <td><p>The type of the gRPC client. The type specified will be registered in the service collection as
  562. a transient service.</p>
  563. </td>
  564. </tr>
  565. </tbody>
  566. </table>
  567. <h5 id="Microsoft_Extensions_DependencyInjection_GrpcClientServiceExtensions_AddGrpcClient__1_IServiceCollection_System_String_Action_IServiceProvider_Grpc_Net_ClientFactory_GrpcClientFactoryOptions___remarks">Remarks</h5>
  568. <div class="markdown level1 remarks"><p>
  569. <see cref="!:HttpClient"></see> instances that apply the provided configuration can be retrieved using
  570. <see cref="!:IHttpClientFactory.CreateClient(string)"></see> and providing the matching name.
  571. </p>
  572. <p>
  573. <code data-dev-comment-type="typeparamref" class="typeparamref">TClient</code> instances constructed with the appropriate <see cref="!:HttpClient"></see>
  574. can be retrieved from <see cref="!:IServiceProvider.GetService(Type)"></see> (and related methods) by providing
  575. <code data-dev-comment-type="typeparamref" class="typeparamref">TClient</code> as the service type.
  576. </p>
  577. <p>
  578. The <see cref="!:IServiceProvider"></see> argument provided to <code data-dev-comment-type="paramref" class="paramref">configureClient</code> will be
  579. a reference to a scoped service provider that shares the lifetime of the handler being constructed.
  580. </p>
  581. </div>
  582. </article>
  583. </div>
  584. <div class="hidden-sm col-md-2" role="complementary">
  585. <div class="sideaffix">
  586. <nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
  587. <!-- <p><a class="back-to-top" href="#top">Back to top</a><p> -->
  588. </nav>
  589. </div>
  590. </div>
  591. </div>
  592. </div>
  593. <footer>
  594. <div class="grad-bottom"></div>
  595. <div class="footer">
  596. <div class="container">
  597. <span class="pull-right">
  598. <a href="#top">Back to top</a>
  599. </span>
  600. <span>Generated by <strong>DocFX</strong></span>
  601. </div>
  602. </div>
  603. </footer>
  604. </div>
  605. <script type="text/javascript" src="../styles/docfx.vendor.js"></script>
  606. <script type="text/javascript" src="../styles/docfx.js"></script>
  607. <script type="text/javascript" src="../styles/main.js"></script>
  608. </body>
  609. </html>