DevNet.Autowired 1.0.18

dotnet add package DevNet.Autowired --version 1.0.18
                    
NuGet\Install-Package DevNet.Autowired -Version 1.0.18
                    
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="DevNet.Autowired" Version="1.0.18" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DevNet.Autowired" Version="1.0.18" />
                    
Directory.Packages.props
<PackageReference Include="DevNet.Autowired" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DevNet.Autowired --version 1.0.18
                    
#r "nuget: DevNet.Autowired, 1.0.18"
                    
#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.
#:package DevNet.Autowired@1.0.18
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DevNet.Autowired&version=1.0.18
                    
Install as a Cake Addin
#tool nuget:?package=DevNet.Autowired&version=1.0.18
                    
Install as a Cake Tool

DevNet.Autowired

Customize AutowiredControllerActivator

Attribute Autowired of AspNet.Core.

version

1.0.16          发布
1.0.18          修正控制器里 Autowired 循环依赖

example

Attribute Autowired

Controller inherit DevNet.Autowired.IAutowiredService

Service,Interface inherit DevNet.Autowired.IAutowiredService

Run:

var builder = WebApplication.CreateBuilder(args);

build.Host.UseAutowiredServiceProvider()

......

public void ConfigureServices(IServiceCollection services) {

    // can use DevNet.Service framework 
    // inherit Interface ITransient/IScoped/ISingleton 
    // to auto Register Service

    services.AddServcie<ITestService1,TestService1>();
    services.AddServcie<ITestService2,TestService2>();
    ......

    services.AddControllersWithViews()
             // 开启控制器 Autowired 注入
            .AddControllersAsServices()
            .AddAutowiredControllerActivator();

}

......

Services:

public interface IBaseServcie : IAutowiredService {

}

public class BaseService : AutowiredServcie , IBaseServcie {

}

// 开启支持循环依赖,默认关闭
[SupportCircularDependency]     
public interface ITestService1 : IBaseServcie {

    void Method1();

}

// 开启支持循环依赖,默认关闭
[SupportCircularDependency]     
public interface ITestService2 : IBaseServcie {

    void Method2();

}

public class TestService1 : BaseService , ITestService1 {

    [Autowired]
    ITestService2 testService2 = null;

    public string Method1() {
        testServie2.Method2();

        ......

    } 
}

public class TestService2 : BaseService , ITestService2 {

    // 循环依赖 
    // use SupportCircularDependencyAttribute
    [Autowired]
    ITestService1 testService1 = null;

    public string Method2() {

        Other:

        ITestService1 testService = App.GetService<ITestService1>();

        ......

    }
}

Controller:

public class BaseController : ControllerBase , IAutowiredService {

    public bool HasAutowired
    {
        get; set;
    }

}

public class TestController : BaseController {

    [Autowired]
    ITestService1 testService1 = null;

    public IActionResult TestAction() {
        testServie1.Method1();

        ......
    }

}
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 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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.
  • net7.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on DevNet.Autowired:

Package Downloads
DevNet.Service

DevNet Service framework of AspNet.Core.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.18 168 4/28/2024
1.0.16 181 3/30/2024
1.0.15 147 3/30/2024