Table of Contents

Class StronglyTypedResourceReference<T>

Namespace
Acuit.Pinpoint.ResourceManagement
Assembly
Acuit.Pinpoint.ResourceManagement.Abstractions.dll

A strongly-typed resource reference wrapper.

public sealed class StronglyTypedResourceReference<T> : IResourceReference<T>, IResourceReference, IDisposable

Type Parameters

T

The resource value type.

Inheritance
StronglyTypedResourceReference<T>
Implements
Inherited Members
Extension Methods

Remarks

This can be used by resource provider implementations to provide strongly-typed resource references via an extension method like this:

public static class MyTypeResourceExtensions
{
    public static IResourceReference<MyType> CreateMyTypeResourceReference(this IResourceProvider resourceProvider, string myResourceName)
    {
        return new StronglyTypedResourceReference<MyType>(resourceProvider.CreateResourceReference(MyTypeResourceUrlHelpers.CreateResourceUrl(myResourceName)));
    }
}

Constructors

StronglyTypedResourceReference(IResourceReference)

Initializes a new instance of the StronglyTypedResourceReference<T> class.

public StronglyTypedResourceReference(IResourceReference resourceReference)

Parameters

resourceReference IResourceReference

The resource reference.

Exceptions

ArgumentNullException

resourceReference is null.

Methods

Dispose()

Closes and releases all resources used by the object.

public void Dispose()

GetChangeToken()

Returns a IChangeToken that can be used to observe when this resource value changes.

public IChangeToken GetChangeToken()

Returns

IChangeToken

A IChangeToken.

Remarks

The change token will indicate a change has occurred upon the first completed attempt to retrieve the resource value, whether successful or not; and then subsequently each time the resource value changes.

The returned change token will raise callbacks.

The proper way to ensure all changes are noted is always to call this first to retrieve the change token, before retrieving the resource value via GetValueAsync(CancellationToken).

Exceptions

ObjectDisposedException

The object has been disposed.

GetValueAsync(CancellationToken)

Gets the resource value.

public Task<T> GetValueAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A cancellation token that can be used to request canceling retrieving the resource.

Returns

Task<T>

A task that represents the asynchronous operation. The value of its Result property contains the resource value.

Remarks

See the remarks for GetValueAsync(CancellationToken) for more information.

Exceptions

InvalidCastException

The resource value could not be cast to type T.

ObjectDisposedException

The object has been disposed.

Exception

The resource could not be retrieved.