Interface IServiceBroker
- Namespace
- Microsoft.ServiceHub.Framework
- Assembly
- Microsoft.ServiceHub.Framework.dll
Provides access to arbitrary services by activating them if necessary and returning an object that may be used to communicate with it.
public interface IServiceBroker
- Extension Methods
Methods
GetPipeAsync(ServiceMoniker, ServiceActivationOptions, CancellationToken)
Requests access to some service through an IDuplexPipe.
ValueTask<IDuplexPipe?> GetPipeAsync(ServiceMoniker serviceMoniker, ServiceActivationOptions options = default, CancellationToken cancellationToken = default)
Parameters
serviceMonikerServiceMonikerThe moniker for the service.
optionsServiceActivationOptionsAdditional options that alter how the service may be activated or provide additional data to the service constructor.
cancellationTokenCancellationTokenA cancellation token.
Returns
- ValueTask<IDuplexPipe>
The duplex pipe that may be used to communicate with the service; or null if no matching service could be found. This should be disposed when no longer required.
Exceptions
- ServiceCompositionException
Thrown when a service discovery or activation error occurs, or when the only service activation option is local service host activation since this overload does not accept a ServiceRpcDescriptor parameter.
GetProxyAsync<T>(ServiceRpcDescriptor, ServiceActivationOptions, CancellationToken)
Requests access to some service through a client proxy.
ValueTask<T?> GetProxyAsync<T>(ServiceRpcDescriptor serviceDescriptor, ServiceActivationOptions options = default, CancellationToken cancellationToken = default) where T : class
Parameters
serviceDescriptorServiceRpcDescriptorAn descriptor of the service.
optionsServiceActivationOptionsAdditional options that alter how the service may be activated or provide additional data to the service constructor.
cancellationTokenCancellationTokenA cancellation token.
Returns
- ValueTask<T>
The client proxy that may be used to communicate with the service; or null if no matching service could be found. This should be disposed when no longer required if the instance returned implements IDisposable.
Type Parameters
TThe type of client proxy to create.
Exceptions
- ServiceCompositionException
Thrown when a service discovery or activation error occurs.
Events
AvailabilityChanged
Occurs when a service previously queried for since the last AvailabilityChanged event may have changed availability.
event EventHandler<BrokeredServicesChangedEventArgs>? AvailabilityChanged
Event Type
Remarks
Not all service availability changes result in raising this event. Only those changes that impact services queried for on this IServiceBroker instance will result in an event being raised. Changes already broadcast in a prior event are not included in a subsequent event. The data included in this event may be a superset of the minimum described here.