ToolNET.Autofac
5.0.4
dotnet add package ToolNET.Autofac --version 5.0.4
NuGet\Install-Package ToolNET.Autofac -Version 5.0.4
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ToolNET.Autofac" Version="5.0.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ToolNET.Autofac --version 5.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ToolNET.Autofac, 5.0.4"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install ToolNET.Autofac as a Cake Addin #addin nuget:?package=ToolNET.Autofac&version=5.0.4 // Install ToolNET.Autofac as a Cake Tool #tool nuget:?package=ToolNET.Autofac&version=5.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
1.webapi使用方式:
//在Startup.cs类中加入下列方法
/// <summary>
/// 依赖注入
/// </summary>
/// <param name="builder"></param>
public void ConfigureContainer(ContainerBuilder builder)
{
//使用Autofac注入
builder.UseAutofac<ControllerModule>();
}
//添加Autofac依赖注入
services.AddAutofac();
//在Program中指定
host.UseServiceProviderFactory(new AutofacServiceProviderFactory());
2.服务进程使用方式
/// <summary>
/// 创建主机
/// </summary>
/// <param name="args"></param>
/// <returns></returns>
public static IHost CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureContainer<ContainerBuilder>(builder => builder.UseAutofac())
.ConfigureServices((context, services) =>
{
services.AddHostedService<ConsumerHostService>();
}).Build();
3.其他说明
/// <summary>
/// 依赖注入接口,IOC都要实现这个接口
/// </summary>
public interface IUseAutofac
{
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net5.0
- Autofac.Extensions.DependencyInjection (>= 8.0.0)
- Microsoft.AspNetCore.Mvc (>= 2.2.0)
- ToolNET.Infrastructure.Reflection (>= 5.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.