Specky6 1.1.0
See the version list below for details.
dotnet add package Specky6 --version 1.1.0
NuGet\Install-Package Specky6 -Version 1.1.0
<PackageReference Include="Specky6" Version="1.1.0" />
paket add Specky6 --version 1.1.0
#r "nuget: Specky6, 1.1.0"
// Install Specky6 as a Cake Addin #addin nuget:?package=Specky6&version=1.1.0 // Install Specky6 as a Cake Tool #tool nuget:?package=Specky6&version=1.1.0
Specky6
Lightweight wrapper to assist injection, using attributes, using the built in DI model integrated in .NET 6 and up.
Required at builder.Services to add Specks
builder.Services.AddSpecks();
Examples (If you're familiar with .NET's built in injection then the naming here should be straight forward.)
Transient
Transient will inject a new instance for every request.
[Transient]
public class MyClass { ... }
// Equivalent to builder.Services.AddTransient<MyClass>();
[TransientAs(typeof(IMyClass))]
public class MyClass : IMyClass { ... }
// Equivalent to builder.Services.AddTransient<IMyClass, MyClass>();
Scoped
Scoped will inject a new instance for every session, typically, in a web app for example, this is each time the Http connection is reset.
[Scoped]
public class MyClass { ... }
// Equivalent to builder.Services.AddScoped<MyClass>();
[ScopedAs(typeof(IMyClass))]
public class MyClass : IMyClass { ... }
// Equivalent to builder.Services.AddScoped<IMyClass, MyClass>();
Singleton
Singleton will inject a the same instance for the lifetime of the application.
[Scoped]
public class MyClass { ... }
// Equivalent to builder.Services.AddSingleton<MyClass>();
[ScopedAs(typeof(IMyClass))]
public class MyClass : IMyClass { ... }
// Equivalent to builder.Services.AddSingleton<IMyClass, MyClass>();
Using Speck attributes across multiple projects / assemblies
In order to scan for specks across multiple assemblies you need to pass those assemblies to the AddSpecks method. Note: Don't forget to include the assembly you are working in, assuming you will have Specks there also.
builder.Services.AddSpecks(new []
{
typeof(Program).Assembly,
typeof(MyProject2.SomeNamespace.SomeType).Assembly,
typeof(MyProject3.AnotherNamespace.IInterfaceForSomething).Assembly
});
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 was computed. 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 was computed. 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. |
-
net6.0
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.