แชร์ผ่าน


AutoClientAttribute Class

Definition

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
AutoClientAttribute
Attributes

Examples

[AutoClient("MyClient")]
interface IMyDependencyClient
{
}

Remarks

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.

Constructors

AutoClientAttribute(String, String)

Initializes a new instance of the AutoClientAttribute class.

AutoClientAttribute(String)

Initializes a new instance of the AutoClientAttribute class.

Properties

CustomDependencyName

Gets the custom dependency name of the API. This is used in generated telemetry.

HttpClientName

Gets the HTTP client name of the API.

Applies to