源码架构
Furion
创建采用多层分层设计,主要设计是 自动抽象工厂
和 DDD 领域驱动设计
相结合。
Furion
框架项目结构如下:
Furion.Tests
:测试层Solution Items
:解决方案配置层Furion
:框架核心层Furion.Application
:业务应用层Furion.Core
:仓储实体层Furion.Database.Migrations
:架构维护层Furion.EntityFramework.Core
:EF Core 配置层Furion.Web.Core
:Web 核心层Furion.Web.Entry
:Web 入口层/启动层
Furion.Tests
测试层
Furion.Tests
是项目的测试层,目前还未整理完成。
Solution Items
解决方案配置层
源码结构:
Solution Items └.editorconfig
Solution Items
是用来配置解决方案中一些全局配置的,如每个文件的顶部版权信息,如:
// ----------------------------------------------------------------------------- // 让 .NET 开发更简单,更通用,更流行。 // Copyright © 2020 Furion, Baiqian Co.,Ltd. // // 框架名称:Furion // 框架作者:百小僧 // 框架版本:1.0.0 // 源码地址:Gitee:https://gitee.com/monksoul/Furion // Github:https://github.com/monksoul/Furion // 开源协议:Apache-2.0(http://www.apache.org/licenses/LICENSE-2.0) // -----------------------------------------------------------------------------
相关配置在 .editorconfig
最后面一行,如:
# Rules in this file were initially inferred by Visual Studio IntelliCode from the D:\MONK\Furion\framework codebase based on best match to current usage at 2020/9/2 # You can modify the rules from these initially generated values to suit your own policies # You can learn more about editorconfig here: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference [*.cs] #Core editorconfig formatting - indentation #use soft tabs (spaces) for indentation indent_style = space #Formatting - new line options #place else statements on a new line csharp_new_line_before_else = true #require members of anonymous types to be on separate lines csharp_new_line_before_members_in_anonymous_types = true #require members of object intializers to be on separate lines csharp_new_line_before_members_in_object_initializers = true #require braces to be on a new line for accessors, methods, control_blocks, types, lambdas, object_collection_array_initializers, anonymous_types, and properties (also known as "Allman" style) csharp_new_line_before_open_brace = accessors, methods, control_blocks, types, lambdas, object_collection_array_initializers, anonymous_types, properties #Formatting - organize using options #do not place System.* using directives before other using directives dotnet_sort_system_directives_first = false #Formatting - spacing options #require a space before the colon for bases or interfaces in a type declaration csharp_space_after_colon_in_inheritance_clause = true #require a space after a keyword in a control flow statement such as a for loop csharp_space_after_keywords_in_control_flow_statements = true #require a space before the colon for bases or interfaces in a type declaration csharp_space_before_colon_in_inheritance_clause = true #remove space within empty argument list parentheses csharp_space_between_method_call_empty_parameter_list_parentheses = false #remove space between method call name and opening parenthesis csharp_space_between_method_call_name_and_opening_parenthesis = false #do not place space characters after the opening parenthesis and before the closing parenthesis of a method call csharp_space_between_method_call_parameter_list_parentheses = false #remove space within empty parameter list parentheses for a method declaration csharp_space_between_method_declaration_empty_parameter_list_parentheses = false #place a space character after the opening parenthesis and before the closing parenthesis of a method declaration parameter list. csharp_space_between_method_declaration_parameter_list_parentheses = false #Formatting - wrapping options #leave code block on single line csharp_preserve_single_line_blocks = true #leave statements and member declarations on the same line csharp_preserve_single_line_statements = true #Style - Code block preferences #prefer no curly braces if allowed csharp_prefer_braces = false:suggestion #Style - expression bodied member options #prefer expression-bodied members for accessors csharp_style_expression_bodied_accessors = true:suggestion #prefer block bodies for constructors csharp_style_expression_bodied_constructors = false:suggestion #prefer block bodies for methods csharp_style_expression_bodied_methods = false:suggestion #prefer expression-bodied members for properties csharp_style_expression_bodied_properties = true:suggestion #Style - expression level options #prefer out variables to be declared inline in the argument list of a method call when possible csharp_style_inlined_variable_declaration = true:suggestion #prefer the language keyword for member access expressions, instead of the type name, for types that have a keyword to represent them dotnet_style_predefined_type_for_member_access = true:suggestion #Style - Expression-level preferences #prefer default over default(T) csharp_prefer_simple_default_expression = true:suggestion #prefer objects to be initialized using object initializers when possible dotnet_style_object_initializer = true:suggestion #prefer inferred anonymous type member names dotnet_style_prefer_inferred_anonymous_type_member_names = false:suggestion #prefer inferred tuple element names dotnet_style_prefer_inferred_tuple_names = true:suggestion #Style - implicit and explicit types #prefer var over explicit type in all cases, unless overridden by another code style rule csharp_style_var_elsewhere = true:suggestion #prefer var is used to declare variables with built-in system types such as int csharp_style_var_for_built_in_types = true:suggestion #prefer var when the type is already mentioned on the right-hand side of a declaration expression csharp_style_var_when_type_is_apparent = true:suggestion #Style - language keyword and framework type options #prefer the language keyword for local variables, method parameters, and class members, instead of the type name, for types that have a keyword to represent them dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion #Style - Miscellaneous preferences #prefer local functions over anonymous functions csharp_style_pattern_local_over_anonymous_function = true:suggestion #Style - modifier options #prefer accessibility modifiers to be declared except for public interface members. This will currently not differ from always and will act as future proofing for if C# adds default interface methods. dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion #Style - Modifier preferences #when this rule is set to a list of modifiers, prefer the specified ordering. csharp_preferred_modifier_order = public,private,internal,protected,virtual,static,async,abstract,readonly,sealed,override:suggestion #Style - qualification options #prefer fields not to be prefaced with this. or Me. in Visual Basic dotnet_style_qualification_for_field = false:suggestion #prefer methods not to be prefaced with this. or Me. in Visual Basic dotnet_style_qualification_for_method = false:suggestion #prefer properties not to be prefaced with this. or Me. in Visual Basic dotnet_style_qualification_for_property = false:suggestion # Add file header file_header_template = -----------------------------------------------------------------------------\nFur 是 .NET 5 平台下企业应用开发最佳实践框架。\nCopyright © 2020 Furion, Baiqian Co.,Ltd.\n\n框架名称:Furion\n框架作者:百小僧\n框架版本:1.0.0\n源码地址:Gitee:https://gitee.com/monksoul/Furion \n Github:https://github.com/monksoul/Furion \n开源协议:Apache-2.0(http://www.apache.org/licenses/LICENSE-2.0)\n-----------------------------------------------------------------------------
Furion
核心层
Furion
核心层是 Furion
框架的中心,也是 Furion
能够支撑起来的必备层。
源码结构:
Furion ├─Furion.csproj ├─Furion.csproj.user ├─FurStartup.cs ├─ViewEngine | ├─IViewEngine.cs | ├─ViewEngine.cs | ├─Templates | | ├─IViewEngineCompiledTemplate.cs | | ├─IViewEngineTemplate.cs | | ├─ViewEngineCompiledTemplate.cs | | └ViewEngineTemplate.cs | ├─Options | | └ViewEngineCompilationOptions.cs | ├─Models | | └AnonymousTypeWrapper.cs | ├─Exceptions | | ├─ViewEngineCompilationException.cs | | └ViewEngineException.cs | ├─Compilations | | ├─IViewEngineCompilationOptionsBuilder.cs | | └ViewEngineCompilationOptionsBuilder.cs ├─UnifyResult | ├─Providers | | ├─IUnifyResultProvider.cs | | └RESTfulResultProvider.cs | ├─Models | | └RESTfulResult.cs | ├─Filters | | └SuccessUnifyResultFilter.cs | ├─Extensions | | └UnifyResultServiceCollectionExtensions.cs ├─SpecificationDocument | ├─Options | | └SpecificationDocumentSettingsOptions.cs | ├─Models | | ├─GroupOrder.cs | | ├─SpecificationOpenApiInfo.cs | | ├─SpecificationOpenApiSecurityRequirementItem.cs | | └SpecificationOpenApiSecurityScheme.cs | ├─Extensions | | ├─SpecificationDocumentApplicationBuilderExtensions.cs | | └SpecificationDocumentServiceCollectionExtensions.cs | ├─Builders | | └SpecificationDocumentBuilder.cs | ├─Assets | | └index-mini-profiler.html ├─ObjectMapper | ├─Extensions | | └ObjectMapperServiceCollectionExtensions.cs | ├─Dependencies | | └IObjectMapper.cs ├─LinqBuilder | ├─Visitors | | └ParameterReplaceExpressionVisitor.cs | ├─Extensions | | └LinqExtensions.cs | ├─Builders | | └LinqExpression.cs ├─FriendlyException | ├─Oops.cs | ├─Providers | | └IErrorCodeTypeProvider.cs | ├─Options | | └ErrorCodeMessageSettingsOptions.cs | ├─Models | | └MethodIfException.cs | ├─Filters | | └FriendlyExceptionFilter.cs | ├─Extensions | | └FriendlyExceptionServiceCollectionExtensions.cs | ├─Attributes | | ├─ErrorCodeItemMetadataAttribute.cs | | ├─ErrorCodeTypeAttribute.cs | | └IfExceptionAttribute.cs ├─DynamicApiController | ├─Penetrates.cs | ├─Providers | | └DynamicApiControllerFeatureProvider.cs | ├─Options | | └DynamicApiControllerSettingsOptions.cs | ├─Models | | └ParameterRouteTemplate.cs | ├─Extensions | | └DynamicApiControllerServiceCollectionExtensions.cs | ├─Enums | | └ApiSeats.cs | ├─Dependencies | | └IDynamicApiController.cs | ├─Conventions | | └DynamicApiControllerApplicationModelConvention.cs | ├─Attributes | | ├─ApiDescriptionSettingsAttribute.cs | | ├─ApiSeatAttribute.cs | | └DynamicApiControllerAttribute.cs ├─DependencyInjection | ├─Options | | └DependencyInjectionSettingsOptions.cs | ├─Models | | └ExternalService.cs | ├─Extensions | | └DependencyInjectionServiceCollectionExtensions.cs | ├─Enums | | ├─InjectionActions.cs | | ├─InjectionPatterns.cs | | └RegisterType.cs | ├─Dependencies | | ├─IPrivateDependency.cs | | ├─IScoped.cs | | ├─ISingleton.cs | | ├─ITransient.cs | | ├─Proxies | | | └IDispatchProxy.cs | ├─Attributes | | ├─InjectionAttribute.cs | | └SkipScanAttribute.cs ├─DataValidation | ├─Validators | | └DataValidator.cs | ├─Providers | | └IValidationMessageTypeProvider.cs | ├─Options | | └ValidationTypeMessageSettingsOptions.cs | ├─Models | | └DataValidationResult.cs | ├─Filters | | └DataValidationFilter.cs | ├─Extensions | | ├─DataValidationExtensions.cs | | └DataValidationServiceCollectionExtensions.cs | ├─Enums | | ├─ValidationPattern.cs | | └ValidationTypes.cs | ├─Attributes | | ├─DataValidationAttribute.cs | | ├─NonValidationAttribute.cs | | ├─ValidationItemMetadataAttribute.cs | | ├─ValidationMessageAttribute.cs | | ├─ValidationMessageTypeAttribute.cs | | └ValidationTypeAttribute.cs ├─DataEncryption | ├─AESEncryption.cs | ├─DESCEncryption.cs | └MD5Encryption.cs ├─DatabaseAccessor | ├─UnitOfWork | | ├─Filters | | | └UnitOfWorkFilter.cs | | ├─Attributes | | | ├─NonTransactAttribute.cs | | | └UnitOfWorkAttribute.cs | ├─Repositories | | ├─EFCoreRepository.cs | | ├─IMSRepository.cs | | ├─IRepository.cs | | ├─ISqlRepository.cs | | ├─MSRepository.cs | | ├─SqlRepository.cs | | ├─Implantations | | | ├─DeletableRepository.cs | | | ├─InsertableRepository.cs | | | ├─OperableRepository.cs | | | ├─ReadableRepository.cs | | | ├─SqlExecutableRepository.cs | | | ├─SqlReaderRepository.cs | | | ├─UpdateableRepository.cs | | | └WritableRepository.cs | | ├─Dependencies | | | ├─IDeletableRepository.cs | | | ├─IInsertableRepository.cs | | | ├─IOperableRepository.cs | | | ├─IReadableRepository.cs | | | ├─IRepositoryDependency.cs | | | ├─ISqlExecutableRepository.cs | | | ├─ISqlReaderRepository.cs | | | ├─IUpdateableRepository.cs | | | └IWritableRepository.cs | ├─Pools | | ├─DbContextPool.cs | | └IDbContextPool.cs | ├─MultiTenants | | ├─Locators | | | └MultiTenantDbContextLocator.cs | | ├─Enums | | | └MultiTenantOptions.cs | | ├─Entities | | | └Tenant.cs | | ├─Dependencies | | | ├─IMultiTenantOnDatabase.cs | | | ├─IMultiTenantOnSchema.cs | | | ├─IMultiTenantOnTable.cs | | | └IPrivateMultiTenant.cs | ├─Models | | ├─DbProvider.cs | | ├─PagedList.cs | | ├─ProcedureOutputResult.cs | | ├─ProcedureOutputValue.cs | | ├─SqlTemplate.cs | | └SqlTemplateParameter.cs | ├─Locators | | ├─IDbContextLocator.cs | | └MasterDbContextLocator.cs | ├─Interceptors | | ├─DbContextSaveChangesInterceptor.cs | | ├─SqlCommandProfilerInterceptor.cs | | └SqlConnectionProfilerInterceptor.cs | ├─Helpers | | └DbHelpers.cs | ├─Extensions | | ├─DatabaseAccessorServiceCollectionExtensions.cs | | ├─PagedQueryableExtensions.cs | | ├─Repositories | | | ├─IEntityExtensions.cs | | | ├─IEntityWithDbContextLocatorExtensions.cs | | | └SqlExtensions.cs | | ├─DatabaseProvider | | | ├─DatabaseProviderServiceCollectionExtensions.cs | | | └Penetrates.cs | | ├─DatabaseFacade | | | ├─DbDataConvertExtensions.cs | | | ├─DbObjectExtensions.cs | | | └SqlAdoNetExtensions.cs | ├─Enums | | ├─DbFunctionType.cs | | ├─EFCoreErrorCodes.cs | | └ManualOptions.cs | ├─Entities | | ├─Dependencies | | | ├─Entity.cs | | | ├─EntityBase.cs | | | ├─EntityNotKey.cs | | | ├─IEntity.cs | | | └IEntityNotKey.cs | | ├─Configures | | | ├─IEntitySeedData.cs | | | ├─IEntityTypeBuilder.cs | | | ├─IModelBuilderFilter.cs | | | └IPrivateModelBuilder.cs | | ├─Attributes | | | ├─FakeDeleteAttribute.cs | | | ├─NonAutomaticAttribute.cs | | | └QueryableFunctionAttribute.cs | ├─DynamicModels | | ├─DynamicModelCacheKeyFactory.cs | | └IEntityMutableTable.cs | ├─Contexts | | ├─AppDbContext.cs | | ├─Builders | | | ├─AppDbContextBuilder.cs | | | ├─Models | | | | └DbContextCorrelationType.cs | | ├─Attributes | | | └AppDbContextAttribute.cs | ├─Attributes | | └DbParameterAttribute.cs | ├─Advances | | ├─Proxies | | | └SqlDispatchProxy.cs | | ├─Models | | | └SqlProxyMethod.cs | | ├─Dependencies | | | └ISqlDispatchProxy.cs | | ├─Attributes | | | ├─SqlExecuteAttribute.cs | | | ├─SqlFunctionAttribute.cs | | | ├─SqlProcedureAttribute.cs | | | ├─Basics | | | | ├─SqlObjectProxyAttribute.cs | | | | ├─SqlProxyAttribute.cs | | | | └SqlSentenceProxyAttribute.cs ├─CorsAccessor | ├─Options | | └CorsAccessorSettingsOptions.cs | ├─Extensions | | ├─CorsAccessorApplicationBuilderExtensions.cs | | └CorsAccessorServiceCollectionExtensions.cs ├─ConfigurableOptions | ├─Options | | └IConfigurableOptions.cs | ├─Extensions | | └ConfigurableOptionsServiceCollectionExtensions.cs | ├─Attributes | | └OptionsSettingsAttribute.cs ├─Authorization | ├─Penetrates.cs | ├─Requirements | | └AuthorizePolicyRequirement.cs | ├─Providers | | └AuthorizePolicyProvider.cs | ├─Options | | └JWTSettingsOptions.cs | ├─Handlers | | └AuthorizePolicyHandler.cs | ├─Extensions | | └PolicyAuthorizationServiceCollectionExtensions.cs | ├─Attributes | | └AuthorizePolicyAttribute.cs ├─App | ├─App.cs | ├─Startups | | ├─AppStartup.cs | | └HostingStartup.cs | ├─Options | | └AppSettingsOptions.cs | ├─Filters | | └StartupFilter.cs | ├─Extensions | | ├─AppApplicationBuilderExtensions.cs | | ├─AppServiceCollectionExtensions.cs | | ├─WebHostBuilderExtensions.cs | | ├─Types | | | └ObjectExtensions.cs | ├─Attributes | | └AppStartupAttribute.cs
Furion.Application
业务应用层
Furion.Application
业务应用层是最常用的层,几乎所有的业务代码都在这个层中编写。
源码结构:
Furion.Application ├─Furion.Application.Core.csproj ├─Furion.Application.Core.xml └FurApplicationStartup.cs
Furion.Core
仓储实体层
Furion.Core
主要是存储自定义仓储和定义实体的层。
源码结构:
Furion.Core ├─Furion.Core.csproj └FurCoreStartup.cs
Furion.Database.Migrations
数据库架构维护层
Furion.Database.Migrations
主要是用来存放 Database First
和 Code First
生成的维护文件。
源码结构:
Furion.Database.Migrations └Furion.Database.Migrations.csproj
Furion.EntityFramework.Core
数据库上下文配置层
Furion.EntityFramework.Core └Furion.EntityFramework.Core.csproj
Furion.Web.Core
应用核心层
Furion.Web.Core
主要是用来配置 Web 入口一些代码,如 Filter
,Middlewares
等。
源码结构
Furion.Web.Core ├─Furion.Web.Core.xml └FurWebCoreStartup.cs
Furion.Web.Entry
应用入口层
Furion.Web.Entry
是我们的应用层,也就是我们的 Web
项目层,发布层。
源码结构:
Furion.Web.Entry ├─appsettings.Development.json ├─appsettings.json ├─Furion.Web.Entry.csproj ├─Furion.Web.Entry.csproj.user ├─Furion.Web.Entry.xml ├─Program.cs ├─Startup.cs ├─wwwroot | └README.md ├─Properties | └launchSettings.json ├─Controllers