Cmpnnt.Pia.DependencyInjection
0.3.0
dotnet add package Cmpnnt.Pia.DependencyInjection --version 0.3.0
NuGet\Install-Package Cmpnnt.Pia.DependencyInjection -Version 0.3.0
<PackageReference Include="Cmpnnt.Pia.DependencyInjection" Version="0.3.0" />
paket add Cmpnnt.Pia.DependencyInjection --version 0.3.0
#r "nuget: Cmpnnt.Pia.DependencyInjection, 0.3.0"
// Install Cmpnnt.Pia.DependencyInjection as a Cake Addin #addin nuget:?package=Cmpnnt.Pia.DependencyInjection&version=0.3.0 // Install Cmpnnt.Pia.DependencyInjection as a Cake Tool #tool nuget:?package=Cmpnnt.Pia.DependencyInjection&version=0.3.0
Cmpnnt.Pia.DependencyInjection
This is a dependency injection helper package for cmpnnt.pia.ctl.
Cmpnnt.Pia.Ctl
is a .NET Native AOT wrapper around piactl
, the Private Internet Access CLI for Windows and Linux.
MacOS support will be added when GitHub makes free runners available.
PIA Sharp's main package, Cmpnnt.Pia.Ctl, has been tested against version 3.3.1 on Windows and Linux. It provides access to every piactl command available in those version on those systems. It might also work on other versions of piactl, provided they expose the same commands with the same parameters. However, this hasn't been tested and nothing is guaranteed.
Dependency Injection
There's a separate dependency injection library you can use if you require DI. Add a reference to
Cmpnnt.Pia.DependencyInjection and include it in your DI container by adding
a call to services.AddPiaCtl()
under ConfigureServices
.
Note: The dependency injection package registers
PiaCtl
as a singleton.
Here's a basic example. You can find the runnable code in the examples project.
using IHost host = Host.CreateDefaultBuilder(args)
.ConfigureServices(services =>
{
services.AddPiaCtl();
services.AddScoped<SomeClass>();
})
.ConfigureLogging(options =>
{
options.ClearProviders();
options.AddConsole();
})
.Build();
Configuration
You can also pass a lambda function to AddPiaCtl
to configure the path to your system's piactl
application, if it differs
from the default. On Windows, the default location is C:\Program Files\Private Internet Access\piactl.exe
.
using IHost host = Host.CreateDefaultBuilder(args)
.ConfigureServices(services =>
{
services.AddPiaCtl(options =>
{
options.PiaPath = @"C:\path\to\piactl.exe";
});
services.AddScoped<SomeClass>();
})
.ConfigureLogging(options =>
{
options.ClearProviders();
options.AddConsole();
})
.Build();
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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. |
-
net8.0
- Cmpnnt.Pia.Ctl (>= 0.1.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0.0)
- Microsoft.Extensions.Options (>= 7.0.1)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 7.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.3.0 | 104 | 8/28/2024 |