OutWit.Communication.Client.DependencyInjection
2.3.0
See the version list below for details.
dotnet add package OutWit.Communication.Client.DependencyInjection --version 2.3.0
NuGet\Install-Package OutWit.Communication.Client.DependencyInjection -Version 2.3.0
<PackageReference Include="OutWit.Communication.Client.DependencyInjection" Version="2.3.0" />
<PackageVersion Include="OutWit.Communication.Client.DependencyInjection" Version="2.3.0" />
<PackageReference Include="OutWit.Communication.Client.DependencyInjection" />
paket add OutWit.Communication.Client.DependencyInjection --version 2.3.0
#r "nuget: OutWit.Communication.Client.DependencyInjection, 2.3.0"
#:package OutWit.Communication.Client.DependencyInjection@2.3.0
#addin nuget:?package=OutWit.Communication.Client.DependencyInjection&version=2.3.0
#tool nuget:?package=OutWit.Communication.Client.DependencyInjection&version=2.3.0
OutWit.Communication.Client.DependencyInjection
Microsoft.Extensions.DependencyInjection integration for WitRPC client, providing easy registration and lifecycle management of WitRPC client services.
Overview
OutWit.Communication.Client.DependencyInjection provides seamless integration between WitRPC clients and the Microsoft Dependency Injection container. It allows you to register WitRPC clients as named services, manage their lifecycle through hosted services, and inject service proxies directly into your application components.
Key features:
- Named client registration - Register multiple WitRPC clients with different configurations
- Typed service registration - Inject service interfaces directly into your classes
- Auto-connect support - Automatically connect clients when the application starts
- Factory pattern - Use
IWitClientFactoryto create and manage clients dynamically
Installation
Install-Package OutWit.Communication.Client.DependencyInjection
Usage
Basic Registration
Register a WitRPC client with a name:
services.AddWitRpcClient("my-service", options =>
{
options.WithWebSocket("ws://localhost:5000");
options.WithJson();
options.WithEncryption();
options.WithAccessToken("your-token");
});
Typed Service Registration
Register a client and automatically create a service proxy:
services.AddWitRpcClient<IMyService>("my-service", options =>
{
options.WithNamedPipe("MyServicePipe");
options.WithJson();
options.WithEncryption();
});
// Now you can inject IMyService directly
public class MyController
{
private readonly IMyService _service;
public MyController(IMyService service)
{
_service = service;
}
}
Auto-Connect on Startup
Enable automatic connection when the application starts:
services.AddWitRpcClient("my-service", options =>
{
options.WithTcp("127.0.0.1", 5000);
options.WithJson();
options.WithAutoReconnect(); // Enable auto-reconnect
}, autoConnect: true, connectionTimeout: TimeSpan.FromSeconds(30));
Using the Factory
For more control, use IWitClientFactory:
public class MyService
{
private readonly IWitClientFactory _factory;
public MyService(IWitClientFactory factory)
{
_factory = factory;
}
public async Task DoWork()
{
var client = _factory.GetClient("my-service");
await client.ConnectAsync(TimeSpan.FromSeconds(5), CancellationToken.None);
var service = _factory.GetService<IMyService>("my-service");
var result = await service.GetDataAsync();
}
}
Multiple Clients
Register multiple clients with different configurations:
services.AddWitRpcClient("service-a", options =>
{
options.WithWebSocket("ws://server-a:5000");
options.WithJson();
});
services.AddWitRpcClient("service-b", options =>
{
options.WithTcp("server-b", 6000);
options.WithMessagePack();
});
Further Documentation
For more about WitRPC and dependency injection patterns, see the official documentation on witrpc.io.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.0)
- OutWit.Communication.Client (>= 2.3.0)
-
net6.0
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.1)
- OutWit.Communication.Client (>= 2.3.0)
-
net7.0
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.1)
- OutWit.Communication.Client (>= 2.3.0)
-
net8.0
- Microsoft.Extensions.Hosting.Abstractions (>= 9.0.11)
- OutWit.Communication.Client (>= 2.3.0)
-
net9.0
- Microsoft.Extensions.Hosting.Abstractions (>= 9.0.11)
- OutWit.Communication.Client (>= 2.3.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on OutWit.Communication.Client.DependencyInjection:
| Package | Downloads |
|---|---|
|
OutWit.Communication.Client.HealthChecks
Health checks integration for WitRPC client, providing ASP.NET Core health checks for monitoring WitRPC client connectivity. |
GitHub repositories
This package is not used by any popular GitHub repositories.