You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
HttpClientStudy/Docs/1.3.0.基础使用.管理客户端.ipynb

110 lines
2.2 KiB
Plaintext

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"dotnet_interactive": {
"language": "csharp"
},
"polyglot_notebook": {
"kernelName": "csharp"
}
},
"source": [
"# HttpClient 初始化与生命周期管理"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"HttpClient 旨在实例化一次,并在应用程序的整个生命周期内重复使用。\n",
"\n",
"为实现复用HttpClient类库默认使用连接池和请求管道可以再结合IoC容器、工厂模式(提供了IHttpClientFactory类库)、复原库Polly"
]
},
{
"cell_type": "markdown",
"metadata": {
"dotnet_interactive": {
"language": "csharp"
},
"polyglot_notebook": {
"kernelName": "csharp"
},
"vscode": {
"languageId": "polyglot-notebook"
}
},
"source": [
"## 1、手动管理直接实例化-强烈不推荐"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 2、手动管理静态类或单例"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 3、手动管理多工具类(每类请求对应一种工具类或单例类)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4、手动管理 + 可复原(Polly)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 5、IoC容器管理类型化的客户端"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 6、客户端工厂管理IHttpClientFactory(需要结合IoC)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 7、综合管理工厂 + 类型化客户端 请求管道 + Polly(默认使用 连接池和IoC容器)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".NET (C#)",
"language": "C#",
"name": ".net-csharp"
},
"language_info": {
"name": "python"
},
"polyglot_notebook": {
"kernelInfo": {
"defaultKernelName": "csharp",
"items": [
{
"aliases": [],
"name": "csharp"
}
]
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}