Struct ServiceBrokerClient.Rental<T>
- Namespace
- Microsoft.ServiceHub.Framework
- Assembly
- Microsoft.ServiceHub.Framework.dll
Provides access to a client proxy as a rental that should be disposed of to signify no active use, allowing it to be disposed of when invalidated.
public struct ServiceBrokerClient.Rental<T> : IDisposable where T : class
Type Parameters
TThe type of the client proxy.
- Implements
- Inherited Members
Constructors
Rental(ServiceBrokerClient, AsyncLazy<object?>, T?)
Initializes a new instance of the ServiceBrokerClient.Rental<T> struct.
public Rental(ServiceBrokerClient client, AsyncLazy<object?> proxy, T? value)
Parameters
clientServiceBrokerClientThe owner.
proxyAsyncLazy<object>The (already evaluated) lazy that we use to track rentals.
valueTThe client proxy itself.
Properties
IsInitialized
Gets a value indicating whether this rental has been initialized (and not yet disposed).
public bool IsInitialized { get; }
Property Value
Remarks
This value can be useful to discern between a default ServiceBrokerClient.Rental<T> instance (where no proxy was yet requested) and one which is initialized but with a null proxy because no matching service was found.
Proxy
Gets the client proxy.
public T? Proxy { get; }
Property Value
- T
Remarks
This value should NOT be disposed directly since it can be shared across invocations of the GetProxyAsync<T>(ServiceRpcDescriptor, CancellationToken) method.
Exceptions
- InvalidOperationException
Thrown if this instance has not been initialized.
- ObjectDisposedException
Thrown if this instance has been disposed (after being initialized).
Methods
Dispose()
Returns the rental of the client proxy, allowing it to be subject to disposal upon invalidation if all rentals have been similarly disposed.
public void Dispose()