DevNet.Service 1.0.16

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

// Install DevNet.Service as a Cake Tool
#tool nuget:?package=DevNet.Service&version=1.0.16                

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 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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.18 111 4/28/2024
1.0.17 107 4/1/2024
1.0.16 105 3/30/2024
1.0.15 100 3/30/2024