zijian666.DI.Configuration 1.1.3-beta

This is a prerelease version of zijian666.DI.Configuration.
dotnet add package zijian666.DI.Configuration --version 1.1.3-beta                
NuGet\Install-Package zijian666.DI.Configuration -Version 1.1.3-beta                
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="zijian666.DI.Configuration" Version="1.1.3-beta" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add zijian666.DI.Configuration --version 1.1.3-beta                
#r "nuget: zijian666.DI.Configuration, 1.1.3-beta"                
#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 zijian666.DI.Configuration as a Cake Addin
#addin nuget:?package=zijian666.DI.Configuration&version=1.1.3-beta&prerelease

// Install zijian666.DI.Configuration as a Cake Tool
#tool nuget:?package=zijian666.DI.Configuration&version=1.1.3-beta&prerelease                

依赖注入配置扩展

使用方式

  1. 服务配置类

class MyServiceOptions
{
    [BindConfiguration(true)]
    public void UseFeature1() { ... }
    [BindConfiguration(true)]
    public void UseFeature2(Feature2Config config) { ... }
}

class Feature2Config
{
   public string Path { get; set; }
   public string Mode { get; set; }
}

  1. 传统调用方式

services.AddMyService(options => 
{
    options.UseFeature1();
    options.UseFeature2(new Feature2Config { Path = "xxxx", Mode = "yyyy" });
});

  1. 使用配置文件方式调用 3.1. 添加配置文件
{
   "MyService": {
      "UseFeature1": true,
      "UseFeature2": {
          "Path": "xxxx",
          "Mode": "yyyy"
      }
   }
}

3.2. 调用

var configuration = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();
services.AddMyService(options => 
{
    configuration.Configure("MyService", options);
    // configuration.GetSection("MyService").Configure(options); // 隔离其他节点的配置
});

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on zijian666.DI.Configuration:

Package Downloads
zijian666.WebApiExtensions

用于快速创建简单易用的标准化WebApi项目

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.3-beta 55 9/18/2024
1.1.0.15-beta 95 6/24/2024

UPLOGS.md