Y.Module
2.0.0
dotnet add package Y.Module --version 2.0.0
NuGet\Install-Package Y.Module -Version 2.0.0
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="Y.Module" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Y.Module --version 2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Y.Module, 2.0.0"
#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 Y.Module as a Cake Addin #addin nuget:?package=Y.Module&version=2.0.0 // Install Y.Module as a Cake Tool #tool nuget:?package=Y.Module&version=2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
相关模块介绍
Y.Module
模块化类库,参照AbpVnext实现,现已正常使用
使用方式
namespace Calo.Blog.Host
{
public class CaloBlogHostModule : YModule
{
public override void ConfigerService(ConfigerServiceContext context)
{
var configuration = context.GetConfiguartion();
//在这里注入你的服务
//批量注入
context.Services.AddAssembly(assembly: Assembly.GetExecutingAssembly());
}
public override void InitApplication(InitApplicationContext context)
{
var app = context.GetApplicationBuilder();
var env = (IHostingEnvironment)context.ServiceProvider.GetRequiredService<IWebHostEnvironment>();
//在这里使用中间件
}
}
}
//异步初始化
public override async Task LaterInitApplicationAsync(InitApplicationContext context)
{
var scope = context.ServiceProvider.CreateAsyncScope();
var minioService = scope.ServiceProvider.GetRequiredService<IMinioService>();
//await scope.ServiceProvider
// .GetRequiredService<IMinioService>()
// .CreateDefaultBucket();
await Task.CompletedTask;
}
特性批量注入
//生命周期枚举,是否使用接口,接口类型,注意当是否使用接口为true时,必须添加接口类型
//不使用接口类型,直接注入当前类
[Injection(InjectionEnum.Scoped,true,typeof(ITestInject))]
public class TestInject : ITestInject
{
private readonly ILogger<TestInject> _logger;
public TestInject(ILogger<TestInject> logger)
{
_logger = logger;
}
public void LogInfo()
{
_logger.LogInformation("注入成功");
}
}
//接口自动注入,ISignletonInjection,IScopedInjection,ITrasinInjection
public class MinioService:IMinioService,IScopedInjection
{
}
//使用
context.Services.AddAssembly(Assembly.GetExecutingAssembly());
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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net7.0
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
- Microsoft.Extensions.DependencyInjection (>= 7.0.0)
- Microsoft.Extensions.Hosting (>= 7.0.1)
- Microsoft.Extensions.Hosting.Abstractions (>= 7.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 7.0.1)
- Microsoft.Extensions.Options (>= 7.0.1)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Y.Module:
Package | Downloads |
---|---|
Y.Tools
Package Description |
|
Y.SqlsugarRepository
Package Description |
|
WYG.Common
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.