SDCores 1.0.0
See the version list below for details.
dotnet add package SDCores --version 1.0.0
NuGet\Install-Package SDCores -Version 1.0.0
<PackageReference Include="SDCores" Version="1.0.0" />
paket add SDCores --version 1.0.0
#r "nuget: SDCores, 1.0.0"
// Install SDCores as a Cake Addin
#addin nuget:?package=SDCores&version=1.0.0
// Install SDCores as a Cake Tool
#tool nuget:?package=SDCores&version=1.0.0
SDCores in .Net core
2. DependencyInjectionConfiguration
Why should use DependencyInjectionConfiguration ?
Usually we need:
public interface IServiceA
{
void Do();
}
public class ServiceA :IServiceA
{
void Do(){
// implementation
}
}
public class TestController : ControllerBase
{
private readonly IServiceA _serviceA;
public TestController(IServiceA serviceA)
{
_serviceA = serviceA;
}
}
and then in Program.cs
using ...
var builder = WebApplication.CreateBuilder(args);
...
builder.Services.AddScoped<IServiceA, ServiceA>();
...
And if you have forgot to register your service(s) to the DI engine. This can be so annoying sometimes considering that you have already coded your service interface and its implementation and even used it by constructor injection in your controller or another service
System.InvalidOperationException: Unable to resolve service for type ...
at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetService(IServiceProvider sp, ...
That's why you should use DependencyInjectionConfiguration
[DependencyInjectionAttribute(ServiceLifetime.Transient)]
public interface IServiceA
{
void Do();
}
And then just add this line to your ConfigureService method of your Program.cs like this
builder.Services.AddDependencyInjectionConfiguration(typeof(Program));
In every service interface by using the DependencyInjectionAttribute annotation and passing your desired service lifetime, your service will be automatically registered in the dotnet core DI engine.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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 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. |
-
net7.0
- Aspose.Cells (>= 23.8.0)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 7.0.10)
- Microsoft.AspNetCore.Http.Features (>= 5.0.17)
- Microsoft.EntityFrameworkCore (>= 7.0.10)
- Swashbuckle.AspNetCore.SwaggerGen (>= 6.5.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.