DevNet.Autowired
1.0.15
See the version list below for details.
dotnet add package DevNet.Autowired --version 1.0.15
NuGet\Install-Package DevNet.Autowired -Version 1.0.15
<PackageReference Include="DevNet.Autowired" Version="1.0.15" />
paket add DevNet.Autowired --version 1.0.15
#r "nuget: DevNet.Autowired, 1.0.15"
// Install DevNet.Autowired as a Cake Addin #addin nuget:?package=DevNet.Autowired&version=1.0.15 // Install DevNet.Autowired as a Cake Tool #tool nuget:?package=DevNet.Autowired&version=1.0.15
DevNet.Autowired
Customize AutowiredControllerActivator
Attribute Autowired of AspNet.Core.
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();
}
......
use example:
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 = DevNet.ServiceActivator.Server.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 | Versions 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. |
-
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.