DevNet.Autowired
1.0.16
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package DevNet.Autowired --version 1.0.16
NuGet\Install-Package DevNet.Autowired -Version 1.0.16
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.16" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DevNet.Autowired --version 1.0.16
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: DevNet.Autowired, 1.0.16"
#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 DevNet.Autowired as a Cake Addin #addin nuget:?package=DevNet.Autowired&version=1.0.16 // Install DevNet.Autowired as a Cake Tool #tool nuget:?package=DevNet.Autowired&version=1.0.16
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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. |
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.