AutoClientAttribute Class
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Triggers the generation of REST APIs and provides information about the HTTP client and, optionally, the name of the dependency.
public ref class AutoClientAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Interface)]
[System.Diagnostics.Conditional("CODE_GENERATION_ATTRIBUTES")]
public sealed class AutoClientAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Interface)>]
[<System.Diagnostics.Conditional("CODE_GENERATION_ATTRIBUTES")>]
type AutoClientAttribute = class
inherit Attribute
Public NotInheritable Class AutoClientAttribute
Inherits Attribute
- Inheritance
- Attributes
[AutoClient("MyClient")]
interface IMyDependencyClient
{
}
This attribute triggers the production of REST APIs and provides information about the HTTP client and optionally the name of the dependency. It can only be applied to interfaces and their name must start with an 'I', for example IMyClient
. This attribute must receive as a first parameter the HTTP client name to be retrieved from the IHttpClientFactory. Optionally, it may receive a second parameter that will set the dependency name
used in generated telemetry. If this value is not set, it will use the name of the interface without the leading 'I'. If the interface name ends in 'Client' or 'Api', the dependency name will exclude that. Example: IMyDependencyClient
would result in dependency name MyDependency
.
Auto |
Initializes a new instance of the AutoClientAttribute class. |
Auto |
Initializes a new instance of the AutoClientAttribute class. |
Custom |
Gets the custom dependency name of the API. This is used in generated telemetry. |
Http |
Gets the HTTP client name of the API. |
Продукт | Версії |
---|---|
.NET | 6 (package-provided), 7 (package-provided), 8 (package-provided), 9 (package-provided), 10 (package-provided) |
Відгук про .NET
.NET – це проект із відкритим кодом. Виберіть посилання, щоб надати відгук: