Lite development framework Nop.Framework nopcommerce b2c based on open source projects

 The project is open source users blog Park  Xu collar  release of a development framework based on open source projects nopCommerce b2c, named Nop.Framework, in addition to the electricity supplier business, to retain basic functions.

 .NET developers should know this famous high-quality open source projects b2c -nopCommerce, based EntityFramework and MVC development, with transparent and well-structured solution, combined the best features of open source and commercial software. Official website address: http: //www.nopcommerce.com/, Chinese net: http: //www.nopcn.com/. After downloading the front and rear end are shown below. If you have not find out about the project, it is recommended to download the code from the official website after viewing locally operating results.

  The authors used the framework developed over many projects, in general, to facilitate simple, it integrates many common components and functions of .NET development. Always wanted to share it out, but did not reach busy with work, recently also have the time to write this article, this article will show you how to extract the source Compact Framework attach source (based nopCommerce3.9 version). If you want to know the framework to develop the project through the frame, then read through this article is valuable. Front Note: This source framework has been uploaded to GitHub: https: //github.com/dreling8/Nop.Framework, are interested can follow this project, will follow some other common modules added to it, such as user management (IWorkContext work context), plug-in function, the task module (taskservice), logging, caching, localization. Welcome star to star, your support is my motivation!

  

  

 

 First, understand the project structure

  From the project structure chart, we can see very clear hierarchical division Nop, look at the map I drew level

  

  

 

  1. The presentation layer (the Presentation)

  May also be referred to as the application layer, only concerned with the integration of the front end, the art does not involve any logic implementation. This layer only show for us frame is dispensable, and therefore the layer removed when extracting frame.

  2. The business service layer (Nop.Services)

  整个系统的服务层,提供了对每个领域的接口和实现。这一层非常重要,提供了程序内对展现层的接口服务,不论展现层使用mvc,还是使用winform,异或是给app调用的webapi接口,都需要该层服务。但该层的服务主要是电商的一些服务,对我们框架无用,因此在这个框架中会删除所有服务,只添加一个测试服务

类和接口,应用到项目中你应该在该层添加接口和服务。

 

  3. 数据层(Nop.Data)

  nop在数据层的仓储实现中使用了ef和sqlserver数据库,如果你想扩展,也可以在该层使用其它的ORM映射库和数据库。这一层的大部分功能我们会在框架中将保留。

  4. 基础设施层(Nop.Core)

  包括缓存的实现、配置、领域模型等等。在框架中会保留一部分功能,并将Domain领域模型移出该层做单独项目,为什么要这样做,因为通常情况下,Domain层的调整会比较多,所以我一般将Domain做单独Project,当然你也可以不调整,但框架做了该调整。

  二、删除与业务相关的代码

  我们已经对Nop的整个代码层次结构有了了解,基于以下两点开始修改项目源码:1.框架足够精简,没有任何电商业务。2.核心功能保留。建议在开始前先copy一份源码保留。

  1. Test项目:Tests文件夹下面是测试项目,不是必需的,将它全部移除,开发具体业务,可以再单独添加测试项目。由于是测试项目,删除后整个项目还能跑起来。

  

  2. Presentation展现层:这里的三个项目,分别是前台,后端和两个项目共用的一些模块。和测试项目一样,这里我们也全部移除。

  

  3. Plugin项目:插件项目,同1、2一样,插件也不是必需的,移除所有的插件项目。现在只剩下三个项目了(欢迎关注该项目的github,后续我会专门写篇文章介绍如何添加插件)。

  

  Nop.Services:业务服务层,这一层是程序集内对外接口层,需要保留。删除所有相关的业务服务类,其中日志、帮助、任务等跟系统相关的都删除,目的是更好的展示整个系统的结构。添加一个测试类,暂时什么都不写。

  

  Nop.Data:数据层项目。这层基本不做调整,只删除EF的Mapping映射相关类。

  Nop.Core:基础设施层。删除电商业务相关的Domain,新建项目Nop.Domain。

  报错了,IWorkContext(工作上下文,用于获取用户信息等数据)依赖Domain,删除它。这个过程可能要删除不少文件,直到项目不再报错。完成后我们的项目结构如下,注意我们将Nop.Core中的实体基类移到了Nop.Domain中,到这一步,我们的基础框架结构已经大致出来了。

  

有关该项目的更多说明,请查看作者的博客介绍:http://www.cnblogs.com/dreling/p/6906688.html

作者表示后续将会添加以下这些模块和功能,有兴趣的朋友可关注项目
1.本地化模块 localization
2.用户模块 工作上下文 workcontext
3.任务模块 taskservice
4.日志模块 logservice
5.缓存模块 cache
6.配置模块 config
7.插件功能

Guess you like

Origin www.cnblogs.com/Alex80/p/11582383.html