Rougamo.Extensions.DependencyInjection.Autofac.AspNetCore
8.0.1-preview-1726209340
See the version list below for details.
dotnet add package Rougamo.Extensions.DependencyInjection.Autofac.AspNetCore --version 8.0.1-preview-1726209340
NuGet\Install-Package Rougamo.Extensions.DependencyInjection.Autofac.AspNetCore -Version 8.0.1-preview-1726209340
<PackageReference Include="Rougamo.Extensions.DependencyInjection.Autofac.AspNetCore" Version="8.0.1-preview-1726209340" />
paket add Rougamo.Extensions.DependencyInjection.Autofac.AspNetCore --version 8.0.1-preview-1726209340
#r "nuget: Rougamo.Extensions.DependencyInjection.Autofac.AspNetCore, 8.0.1-preview-1726209340"
// Install Rougamo.Extensions.DependencyInjection.Autofac.AspNetCore as a Cake Addin #addin nuget:?package=Rougamo.Extensions.DependencyInjection.Autofac.AspNetCore&version=8.0.1-preview-1726209340&prerelease // Install Rougamo.Extensions.DependencyInjection.Autofac.AspNetCore as a Cake Tool #tool nuget:?package=Rougamo.Extensions.DependencyInjection.Autofac.AspNetCore&version=8.0.1-preview-1726209340&prerelease
Rougamo.DI
中文 | English
Rougamo.DI
provides a set of IoC/DI extensions for Rougamo that enhance the IoC/DI interaction experience when using Rougamo.
Available Extensions
Package Name | Description |
---|---|
Rougamo.Extensions.DependencyInjection.AspNetCore | Uses the official DependencyInjection and integrates with HttpContext to return the correct scoped IServiceProvider |
Rougamo.Extensions.DependencyInjection.GenericHost | Uses the official DependencyInjection , suitable for non-AspNetCore Generic Host projects |
Rougamo.Extensions.DependencyInjection.Autofac.AspNetCore | Uses Autofac and integrates with HttpContext to return the correct scoped ILifetimeScope |
Rougamo.Extensions.DependencyInjection.Autofac | Uses Autofac , suitable for non-AspNetCore projects |
Rougamo.Extensions.DependencyInjection.Abstractions | The base abstraction package for all other packages |
Rougamo.Extensions.DependencyInjection.AspNetCore.Abstractions | The base abstraction package for all AspNetCore-related packages |
Versioning Guidelines
All version numbers follow the Semantic Versioning (SemVer) format
- The version numbers of the two foundational abstraction packages start from
1.0.0
and increase incrementally:Rougamo.Extensions.DependencyInjection.Abstractions
Rougamo.Extensions.DependencyInjection.AspNetCore.Abstractions
- For Microsoft official DI extension packages, the major version matches the corresponding official package (e.g.,
Microsoft.Extensions.*
):Rougamo.Extensions.DependencyInjection.AspNetCore
Rougamo.Extensions.DependencyInjection.GenericHost
- For Autofac extension packages, the major version matches the corresponding official
Autofac
package:Rougamo.Extensions.DependencyInjection.Autofac.AspNetCore
Rougamo.Extensions.DependencyInjection.Autofac
Rougamo.Extensions.DependencyInjection.AspNetCore
Quick Start
// Register Rougamo (Note: Rougamo does not require registration if you do not need IoC/DI features)
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
// ... other setup steps
builder.Services.AddRougamoAspNetCore();
// ... other setup steps
}
// Accessing IServiceProvider in an aspect
public class TestAttribute : MoAttribute
{
public override void OnEntry(MethodContext context)
{
// Use the extension method GetServiceProvider to obtain the IServiceProvider instance
var services = context.GetServiceProvider();
// Utilize IServiceProvider
var xxx = services.GetService<IXxx>();
}
}
Rougamo.Extensions.DependencyInjection.GenericHost
// Register Rougamo (Note: Rougamo does not require registration if you do not need IoC/DI features)
public static void Main(string[] args)
{
var builder = Host.CreateDefaultBuilder();
// ... other setup steps
builder.ConfigureServices(services => services.AddRougamoGenericHost());
// ... other setup steps
}
// Accessing IServiceProvider in an aspect
public class TestAttribute : MoAttribute
{
public override void OnEntry(MethodContext context)
{
// Use the extension method GetServiceProvider to obtain the IServiceProvider instance
var services = context.GetServiceProvider();
// Utilize IServiceProvider
var xxx = services.GetService<IXxx>();
}
}
Rougamo.Extensions.DependencyInjection.Autofac.AspNetCore
Quick Start
// Register Rougamo (Note: Rougamo does not require registration if you do not need IoC/DI features)
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
builder.Host
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureContainer<ContainerBuilder>(builder =>
{
builder.RegisterRougamoAspNetCore();
});
// Registering IHttpContextAccessor is also required
builder.Services.AddHttpContextAccessor();
}
// Accessing ILifetimeScope in an aspect
public class TestAttribute : MoAttribute
{
public override void OnEntry(MethodContext context)
{
// Use the extension method GetAutofacCurrentScope to obtain the ILifetimeScope instance
var scope = context.GetAutofacCurrentScope();
// Utilize ILifetimeScope
var xxx = scope.Resolve<IXxx>();
}
}
Rougamo.Extensions.DependencyInjection.Autofac
// Register Rougamo (Note: Rougamo does not require registration if you do not need IoC/DI features)
public static void Main(string[] args)
{
var builder = Host.CreateDefaultBuilder();
builder
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureContainer<ContainerBuilder>(builder =>
{
builder.RegisterRougamo();
});
}
// Accessing ILifetimeScope in an aspect
public class TestAttribute : MoAttribute
{
public override void OnEntry(MethodContext context)
{
// Use the extension method GetAutofacCurrentScope to obtain the ILifetimeScope instance
var scope = context.GetAutofacCurrentScope();
// Utilize ILifetimeScope
var xxx = scope.Resolve<IXxx>();
}
}
Usage in Framework Projects
If your project is an older WebForm, WinForm, WPF, or similar project that does not use the Microsoft.Extensions.*
packages, you can directly call the RegisterRougamo
extension method when initializing the ContainerBuilder
.
var builder = new ContainerBuilder();
builder.RegisterRougamo();
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. 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. |
.NET Core | netcoreapp3.1 is compatible. |
-
.NETCoreApp 3.1
- Autofac (>= 8.0.0 && < 9.0.0)
- Autofac.Extensions.DependencyInjection (>= 9.0.0 && < 10.0.0)
- Rougamo.Extensions.DependencyInjection.AspNetCore.Abstractions (>= 1.0.1-preview-1726204848)
- Rougamo.Extensions.DependencyInjection.Autofac (>= 8.0.1-preview-1726209340)
-
net5.0
- Autofac (>= 8.0.0 && < 9.0.0)
- Autofac.Extensions.DependencyInjection (>= 9.0.0 && < 10.0.0)
- Rougamo.Extensions.DependencyInjection.AspNetCore.Abstractions (>= 1.0.1-preview-1726204848)
- Rougamo.Extensions.DependencyInjection.Autofac (>= 8.0.1-preview-1726209340)
-
net6.0
- Autofac (>= 8.0.0 && < 9.0.0)
- Autofac.Extensions.DependencyInjection (>= 9.0.0 && < 10.0.0)
- Rougamo.Extensions.DependencyInjection.AspNetCore.Abstractions (>= 1.0.1-preview-1726204848)
- Rougamo.Extensions.DependencyInjection.Autofac (>= 8.0.1-preview-1726209340)
-
net7.0
- Autofac (>= 8.0.0 && < 9.0.0)
- Autofac.Extensions.DependencyInjection (>= 9.0.0 && < 10.0.0)
- Rougamo.Extensions.DependencyInjection.AspNetCore.Abstractions (>= 1.0.1-preview-1726204848)
- Rougamo.Extensions.DependencyInjection.Autofac (>= 8.0.1-preview-1726209340)
-
net8.0
- Autofac (>= 8.0.0 && < 9.0.0)
- Autofac.Extensions.DependencyInjection (>= 9.0.0 && < 10.0.0)
- Rougamo.Extensions.DependencyInjection.AspNetCore.Abstractions (>= 1.0.1-preview-1726204848)
- Rougamo.Extensions.DependencyInjection.Autofac (>= 8.0.1-preview-1726209340)
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 |
---|---|---|
8.0.1 | 95 | 9/18/2024 |
8.0.1-preview-1726209340 | 86 | 9/13/2024 |
8.0.0 | 123 | 8/22/2024 |
7.0.1 | 86 | 9/18/2024 |
7.0.1-preview-1726208693 | 80 | 9/13/2024 |
7.0.0 | 136 | 8/22/2024 |
6.0.1 | 91 | 9/18/2024 |
6.0.1-preview-1726208008 | 81 | 9/13/2024 |
6.0.0 | 108 | 8/21/2024 |
5.0.1 | 93 | 9/18/2024 |
5.0.1-preview-1726207262 | 78 | 9/13/2024 |
5.0.0 | 110 | 8/21/2024 |
4.0.1 | 94 | 9/18/2024 |
4.0.1-preview-1726205254 | 81 | 9/13/2024 |
4.0.0 | 118 | 8/21/2024 |
4.0.0-priview-1724248067 | 103 | 8/21/2024 |
4.0.0-priview-1724239435 | 100 | 8/21/2024 |
4.0.0-priview-1724238077 | 101 | 8/21/2024 |
4.0.0-preview-1724276951 | 97 | 8/21/2024 |
4.0.0-preview-1724276233 | 96 | 8/21/2024 |
4.0.0-preview-1724259035 | 105 | 8/21/2024 |
- [[#2](https://github.com/inversionhourglass/Rougamo.DI/issues/2)] 修复并行任务创建scope可能导致获取到错误的scope
- AspNetCore项目从默认不支持嵌套scope更改为默认支持嵌套scope
---