Class ProtoResource
A resource described by a release callback, for cases that do not warrant a type of their own.
public sealed class ProtoResource : IProtoResource
- Inheritance
-
ProtoResource
- Implements
- Inherited Members
- Extension Methods
Constructors
ProtoResource(string, string, string, Func<ProtoResourceReleaseContext, ValueTask>, ProtoResourceScope)
public ProtoResource(string id, string kind, string description, Func<ProtoResourceReleaseContext, ValueTask> release, ProtoResourceScope scope = ProtoResourceScope.Test)
Parameters
idstringkindstringdescriptionstringreleaseFunc<ProtoResourceReleaseContext, ValueTask>scopeProtoResourceScope
Properties
Description
Gets a single line describing the resource for the trace, report and viewer.
public string Description { get; }
Property Value
Id
Gets the stable identity of the resource, for example customer:42.
public string Id { get; }
Property Value
Kind
Gets the resource kind, for example database or entity.
public string Kind { get; }
Property Value
Scope
Gets how long the resource lives. Defaults to the test that registered it.
public ProtoResourceScope Scope { get; }
Property Value
Methods
From(string, string, string, Func<ProtoResourceReleaseContext, CancellationToken, ValueTask>)
Creates a resource with an asynchronous release callback.
public static ProtoResource From(string id, string kind, string description, Func<ProtoResourceReleaseContext, CancellationToken, ValueTask> release)
Parameters
idstringkindstringdescriptionstringreleaseFunc<ProtoResourceReleaseContext, CancellationToken, ValueTask>
Returns
ReleaseAsync(ProtoResourceReleaseContext)
Releases the resource. Each resource is released at most once, so implementations do not have to guard against repeated calls, but must tolerate a failed release being reported.
public ValueTask ReleaseAsync(ProtoResourceReleaseContext context)
Parameters
contextProtoResourceReleaseContext