Giter Club home page Giter Club logo

netpro's Introduction

NetPro                   Chinese

.NET Core NuGet NuGet

NetpPro is based on enhanced Startup features development of efficient management Startup implementation, he is cross-platform, written in C# language, and is designed to code low intrusion, low dependency, modular, pluggable, on demand reference, support dotnet3.1, dotnet5.0, dotnet6.0, due to low intrusion, References on demand can be easily upgraded for future higher versions.

Architecture preview

Feature

Compared to the various development frameworks commonly used, NetPro has many advantages:

  • It improves the development and maintenance cost caused by Startup clutter and high integration of components in the framework

  • Low intrusion, based on the NetPro.Startup developed kit can be put into the specified path to achieve plug-in ability, easily expand new functions

  • Low dependency: all development packages based on NetPro.Startup do not depend on each other

  • Easily realize the development according to the business domain, through NetPro.Startup can easily pack the business needs into an assembly, achieve high cohesion within the business, avoid the past controller and business layer, database layer, Startup and other scattered in multiple assemblies

  • Rapid development of microservices, based on NetPro.Startup best practices after the development of business modules can be quickly converted to microservices without changing the code conditions

  • On-demand reference. By enhancing the Startup feature, all the toolkits developed based on NetPro.Startup can be enabled by reference

Getting Started

All preset development kits based on NetPro.Startup please view under src/Library For various development examples and best practices please view under src/sample

Package Manager:

You can install netpro.startup in your project by running the following command

PM> Install-Package NetPro.Startup -Version *

.NET CLI :

dotnet add package NetPro.Startup --version *

PackageReference:

<PackageReference Include="NetPro.Startup" Version="*" />

.NET CLI :

paket add NetPro.Startup --version *

Creating projects through scaffolding (recommended)

1、install netproapiNuGetscaffold

Run the following command to install the scaffold

dotnet new -i netproapi::* 

2、Use scaffolding to create projects

Execute the following command in the specified project folder

dotnet new netproapi -n project name

For example, the current project is IAM

dotnet new netproapi -n IAM

Executing the above command will automatically create the WebApi code solution

Execute

After the development environment runs, the effect is as follows:

 ____  _____        _   _______
|_   \|_   _|      / |_|_   __ \
  |   \ | |  .---.`| |-' | |__) |_ .--.   .--.
  | |\ \| | / /__\\| |   |  ___/[ `/'`\]/ .'`\ \
 _| |_\   |_| \__.,| |, _| |_    | |    | \__. |
|_____|\____|'.__.'\__/|_____|  [___]    '.__.'


[17:40:03] dotnet process id:14520
The enhanced service has started
[17:40:04] loading json files
Service injection sequence:
[17:40:15] apollo已关闭
info: NetProSwaggerServiceExtensions[0]
      NetPro Swagger 已启用
--------------------------------------------------------------------------------------------------------------------------------------
|    Order   |       StartupClassName       |                   Path                   |             Assembly            |  Version  |
--------------------------------------------------------------------------------------------------------------------------------------
| 0          | NetProCoreStartup            | NetPro.Core.Startup.NetProCoreStartup    | NetPro.Core                     |  3.1.13.0 |
--------------------------------------------------------------------------------------------------------------------------------------
| 0          | CheckerStartup               | NetPro.Analysic.CheckerStartup           | NetPro.Checker                  |  3.1.13.0 |
--------------------------------------------------------------------------------------------------------------------------------------
| 0          | ErrorHandlerStartup(default) | NetPro.Web.Api.ErrorHandlerStartup       | NetPro.Web.Api                  |  3.1.13.0 |
--------------------------------------------------------------------------------------------------------------------------------------
| 100        | SwaggerStartup               | NetPro.Swagger.SwaggerStartup            | NetPro.Swagger                  |  3.1.13.0 |
--------------------------------------------------------------------------------------------------------------------------------------
| 100        | StaticFilesStartup(default)  | NetPro.Web.Api.StaticFilesStartup        | NetPro.Web.Api                  |  3.1.13.0 |
--------------------------------------------------------------------------------------------------------------------------------------
| 200        | RoutingStartup(default)      | NetPro.Web.Api.RoutingStartup            | NetPro.Web.Api                  |  3.1.13.0 |
--------------------------------------------------------------------------------------------------------------------------------------
| 300        | CorsStartup                  | NetPro.Web.Api.CorsStartup               | NetPro.Web.Api                  |  3.1.13.0 |
--------------------------------------------------------------------------------------------------------------------------------------
| 400        | ShareBodyStartup             | NetPro.ShareRequestBody.ShareBodyStartup | NetPro.NetProShareRequestBody   |  3.1.13.0 |
--------------------------------------------------------------------------------------------------------------------------------------
| 1000       | EndpointsStartup(default)    | NetPro.Web.Api.EndpointsStartup          | XXX.API (custom)                |  1.0.0.0  |
--------------------------------------------------------------------------------------------------------------------------------------
| 1000       | NetProCsRedisStartup         | NetPro.CsRedis.NetProCsRedisStartup      | NetPro.CsRedis                  |  3.1.13.0 |
--------------------------------------------------------------------------------------------------------------------------------------
| 2147483647 | ApiStartup                   | XXX.API.ApiStartup                       | XXX.API (custom)                |  1.0.0.0  |
--------------------------------------------------------------------------------------------------------------------------------------
| 2147483647 | ApiStartup-1                 | XXX.Plugin.Web.Demo.ApiStartup           | XXX.Plugin.Web.Demo (custom)    |  1.0.0.0  |
--------------------------------------------------------------------------------------------------------------------------------------
| 2147483647 | ApiStartup-2                 | XXX.Plugin.Web.Manager.ApiStartup        | XXX.Plugin.Web.Manager (custom) |  1.0.0.0  |

netpro's People

Contributors

fanweix avatar kamenriderkuuga avatar liuyl1992 avatar robyle avatar tengfengsu avatar yuanchanglong1997 avatar yuefengkai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

netpro's Issues

多语言库移除默认后缀

目前使用多语言库时,直接指定key取对应文本,当key不存在时,会返回一个computedKey,即带有语言后缀的key,原因见:

https://github.com/damienbod/AspNetCoreLocalization/blob/3e88aa6701cde503e1595d529e27770fb0e98f50/src/Localization.SqlLocalizer/DbStringLocalizer/SqlStringLocalizer.cs#L67

建议调整传入Localization.SqlLocalizer的选项,使其在没有对应key的时候直接返回key,当项目需要支持多语言时,则手动增加各种语言对应的信息

关于异常:Unable to resolve service for type 'Microsoft.AspNetCore.Http.IHttpContextAccessor

完整错误信息:
Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: IDasContextAccessor Lifetime: Singleton ImplementationType: Das.Common.DasContextAccessor': Unable to resolve service for type 'Microsoft.AspNetCore.Http.IHttpContextAccessor' while attempting to activate 'Das.Common.DasContextAccessor'.)

InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Http.IHttpContextAccessor' while attempting to activate 'Das.Common.DasContextAccessor

原因分析:
经调试后发现是项目中 NetPro.Web.Api中 RoutingStartup 执行报错导致 RoutingStartup 未能正确执行完毕,从而引起IHttpContextAccessor未被注入,最终导致这个问题的出现。在将 library中NetPro.Web.Api项目的RoutingStartup 源码拷贝下来执行调试后查看错误信息发现是这段代码报错了

mvcBuilder.AddFluentValidation(configuration =>           
{
                string assemblySkipLoadingPattern = "^NetPro.*|^Com.Ctrip*|^Figgle|^Serilog.*|^netstandard|^OpenTracing.Contrib.NetCor|^App.Metrics.AspNetCore|^SkyAPM|^Swashbuckle|^System|^mscorlib|^Microsoft|^AjaxControlToolkit|^Antlr3|^Autofac|^AutoMapper|^Castle|^ComponentArt|^CppCodeProvider|^DotNetOpenAuth|^EntityFramework|^EPPlus|^FluentValidation|^ImageResizer|^itextsharp|^log4net|^MaxMind|^MbUnit|^MiniProfiler|^Mono.Math|^MvcContrib|^Newtonsoft|^NHibernate|^nunit|^Org.Mentalis|^PerlRegex|^QuickGraph|^Recaptcha|^Remotion|^RestSharp|^Rhino|^Telerik|^Iesi|^TestDriven|^TestFu|^UserAgentStringLibrary|^VJSharpCodeProvider|^WebActivator|^WebDev|^WebGrease";
                var assembliesResult = new List<Assembly>();
                foreach (var item in assemblies)
                {
                    if (!Regex.IsMatch(item.FullName, assemblySkipLoadingPattern, RegexOptions.IgnoreCase | RegexOptions.Compiled) && Regex.IsMatch(item.FullName, ".*", RegexOptions.IgnoreCase | RegexOptions.Compiled))
                    {
                        if (!item.IsDynamic)
                            assembliesResult.Add(item);
                    }
                }
                configuration.RegisterValidatorsFromAssemblies(assembliesResult);

                //implicit/automatic validation of child properties 复合对象是否验证
                configuration.ImplicitlyValidateChildProperties = true;
 });

原因是NetPro本身有一个版本的SQLLite程序集,我在使用时又引入了SQLLite的其他版本程序集,而这里的正则表达式又没有排除搜索这两个,所以导致在注册的时候出现冲突

解决办法:
在配置文件中添加

"TypeFinderOption": { "CustomDllPattern": "^XXX.Api*" }

此配置表示仅搜索正则匹配到的程序集,此时只有一个版本的SQLLite,不再报错,问题解决。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.