DevNet.Service
1.0.15
See the version list below for details.
dotnet add package DevNet.Service --version 1.0.15
NuGet\Install-Package DevNet.Service -Version 1.0.15
<PackageReference Include="DevNet.Service" Version="1.0.15" />
paket add DevNet.Service --version 1.0.15
#r "nuget: DevNet.Service, 1.0.15"
// Install DevNet.Service as a Cake Addin #addin nuget:?package=DevNet.Service&version=1.0.15 // Install DevNet.Service as a Cake Tool #tool nuget:?package=DevNet.Service&version=1.0.15
DevNet.Service
DevNet Service framework of AspNet.Core.
Simplify the complex Furion framework
Thanks
Thanks for Furion
example
asp.net.Core Service framework
Run:
Program.cs:
// 默认启动 DevNet.Service.App.Run();
Startup:
public class ApiStartup : AppStartup
{
// 1. 创建 WebApplicationBuilder 之后,添加框架服务时最后调用
public override void ServiceConfigure(IServiceCollection services) {
services.AddControllersWithViews()
// 注入框架相关服务
.AddFrameworkInject()
// 自定义扩展
.AddApiExtension()
// 开启控制器 Autowired 注入
.AddControllersAsServices()
.AddAutowiredControllerActivator();
}
// 2. 添加框架服务后,Build()Application 前调用
public override void WebBuilderConfigure(WebApplicationBuilder webApplicationBuilder) {
//基类为空方法
base.WebBuilderConfigure(webApplicationBuilder);
}
// 3. Application.Run 开始时 IStartupFilter 里调用
public override void ApplicationConfigure(IApplicationBuilder app, IWebHostEnvironment env) {
if (env.IsDevelopment()) {
app.UseDeveloperExceptionPage();
}
//Use框架注入的服务
app.UseFrameworkInject(useInjectOption => {
useInjectOption.ForwardedHeadersOption =
new ForwardedHeadersOptions {
ForwardedHeaders =
ForwardedHeaders.XForwardedFor
| ForwardedHeaders.XForwardedProto
};
useInjectOption.UseKnifeUI = Convert.ToBoolean(App.Configuration["SpecificationDocument:EnableKnifeUI"]);
useInjectOption.RoutePrefix = Convert.ToString(App.Configuration["SpecificationDocument:KnifeUIRoute"]);
});
app.UseApiExtension();
app.UseEndpoints(
endpoints => {
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
}
}
Services:
public interface IBaseServcie : ITransient , IAutowiredService {
// 数据访问对象
// need use DevNet.Core ORM
// can use self ORM
IAppDataManager DataManager
{
get; set;
}
}
public class BaseService : AutowiredServcie , IBaseServcie {
// 数据访问对象
// need use DevNet.Core ORM
// can use self ORM
[Autowired]
public IAppDataManager DataManager
{
get;
set;
}
}
// 开启支持循环依赖,默认关闭
[SupportCircularDependency]
public interface ITestService1 : IBaseServcie {
void Method1();
}
// 开启支持循环依赖,默认关闭
[SupportCircularDependency]
public interface ITestService2 : IBaseServcie {
void Method2();
}
public class TestService1 : BaseService , ITestService1 {
[Autowired]
ITestService2 testService2 = null;
public List<T> Method1() {
List<T> lstRet = DataManager.GetRelationList<T>("fn", "fv");
......
return lstRet;
}
}
public class TestService2 : BaseService , ITestService2 {
// 循环依赖
// use SupportCircularDependencyAttribute
[Autowired]
ITestService1 testService1 = null;
public string Method2() {
Other:
ITestService1 testService = DevNet.ServiceActivator.Server.GetService<ITestService1>();
......
}
}
DynamicController:
public class BaseController : AutowiredService , IDynamicController {
}
[Route("api/test/")] public class TestController : BaseController {
[Autowired]
ITestService1 testService1 = null;
// auto UnifyResult
// url: /api/test/testaction
[HttpPost]
public List<T> TestAction() {
List<T> lstRet = testServie1.Method1();
......
retun lstRet;
}
}
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
- Ben.Demystifier (>= 0.4.1)
- DevNet.Autowired (>= 1.0.15)
- IGeekFan.AspNetCore.Knife4jUI (>= 0.0.16)
- Microsoft.AspNetCore.Mvc.NewtonsoftJson (>= 6.0.28)
- Microsoft.AspNetCore.Razor.Language (>= 6.0.20)
- Microsoft.Extensions.DependencyModel (>= 6.0.0)
- MiniProfiler.AspNetCore.Mvc (>= 4.2.22)
- Swashbuckle.AspNetCore (>= 6.4.0)
- System.Text.Json (>= 6.0.7)
-
net7.0
- Ben.Demystifier (>= 0.4.1)
- DevNet.Autowired (>= 1.0.15)
- IGeekFan.AspNetCore.Knife4jUI (>= 0.0.16)
- Microsoft.AspNetCore.Mvc.NewtonsoftJson (>= 6.0.28)
- Microsoft.AspNetCore.Razor.Language (>= 6.0.20)
- Microsoft.Extensions.DependencyModel (>= 6.0.0)
- MiniProfiler.AspNetCore.Mvc (>= 4.2.22)
- Swashbuckle.AspNetCore (>= 6.4.0)
- System.Text.Json (>= 6.0.7)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.