In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to use Visual Studio to develop applications for classic hierarchical architectures. the content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.
After a year, continue our journey of Apworks framework. In the next article, I will gradually show you how to combine the Apworks framework in Visual Studio and use ASP.NET Web API and MVC to develop applications for classic hierarchical architectures. In this lecture, we first look at the "layers" of the hierarchical architecture and the Visual Studio projects involved, and then we start our application development journey in Visual Studio, starting with the domain model.
Note: although Microsoft has released Visual Studio 2015, but in order to take care of the majority of users of the old version, the following Visual Studio 2013 with Update 4 as a development tool for introduction. In addition, in some scenarios, some of the features of Visual Studio 2013 Ultimate will be required.
The recent situation of Apworks
I haven't introduced you to the Apworks framework for some time. In the last six months, I have done some small refactorings for Apworks, as follows:
Upgrade the supported .NET Framework to 4.5.1
Generic ID is supported on the IEntity interface, which means that in classic hierarchical Apworks applications, entity keys can begin to support a variety of raw data types (key combinations are not currently supported), such as shaping. This change will not have any impact on the existing framework, and the default entity key type is still Guid
Begin to support the operation of asynchronous Commit on the concrete implementation of Unit Of Work, that is, RepositoryContext: you can use CommitAsync for asynchronous commit. More asynchronous methods will be supported in future releases
Update the dependent third-party frameworks to the latest version (of course, these third-party frameworks may have been updated again at the time of writing this article)
Improved the implementation of NHibernate Repository
Performance optimization
You can click https://github.com/daxnet/Apworks directly to enter the open source home page of the Apworks framework, or you can use the following command to obtain the source code of Apworks:
?
1git clone https://github.com/daxnet/Apworks.git case: personal Note Application
Once again, I try to tell you the whole story from an application case, hoping to let you see clearly and understand the nature of the problem. I remember that I also cited a lot of examples in many articles before. Some articles explained the examples, while others gave up halfway and came to an end. Well, in any case, you can't explain the problem step by step without a case. After all, theory also needs to be combined with practice.
This case is a personal note application. At the beginning, I called this subtitle "case: a simple personal note application". After thinking about it, I removed the word "a simple". I think, simple things are not what everyone wants, and everyone can do simple things. it sounds like you can simply solve the problem without the help of any framework or tools. What I want to introduce to you is a complete enterprise application, which should not only implement the basic domain logic, but also include all aspects such as security, performance and so on.
Friends in my circle should know that I have developed a cloud-based personal note-taking system Cloud Notes, and there are also some articles about the technology and development process of Cloud Notes. Yes, the case I'm going to use now has a business background similar to that of a personal note-taking system, but in order to introduce the technical part, I will make its business easier and introduce some best practices for implementing RESTful services, so this case will be similar to Cloud Notes in technical architecture, but there will be some differences in detail. In a word, try to explain the problem in a concise form.
The part involved in this case includes users and permissions. From a business point of view, each user can manage his own notes, and that's all. Being too complicated can make people feel dizzy and reduce the readability of this article. OK, let's name this case EasyMemo.
Theory: hierarchical Architecture and Technology selection
In my previous blog, I introduced the hierarchical architecture, especially when introducing domain-driven design, as well as the heterogeneous event-based command query responsibility separation (CQRS) architecture. This case is developed using the classical hierarchical architecture. Here, I think it is necessary to simply draw the architecture diagram and mark the Microsoft technology we are going to use. On the one hand, this will let you know what technologies we are using, and on the other hand, in the follow-up introduction, you can also see which part of the entire architecture we are currently talking about. See the following figure:
As you can see, during the introduction of the whole case, we will use Entity Framework 6 as the data storage ORM, Microsoft SQL Server as the background database, the domain model layer adapts to the Apworks framework, the application layer task coordination uses the Apworks framework, and provides RESTful services to the outside world through ASP.NET Web API 2. The presentation layer is implemented with ASP.NET MVC 4 plus AngularJS, which of course uses some of the features of Twitter Bootstrap. After all, the package of Bootstrap is installed by default in the standard ASP.NET MVC template.
This is the basic architecture, so let's start building our EasyMemo project in Visual Studio 2013.
Practice: start building a solution
Open Visual Studio 2013, of course, we do not need to use the Ultimate version at this time, because the solution building process will not involve any features related to Visual Studio 2013 Ultimate. In order to make the organization of the projects in the solution more reasonable, it is recommended that you first create a blank solution in Visual Studio 2013. Select 4.5.1 for the .NET Framework version, because the Apworks framework to be used in the future is based on 4.5.1:
When you click the OK button, Visual Studio displays a blank solution in solution Explorer. Next, we create the following new projects in the solution one after another:
EasyMemo.Common: provides types and components that can be applied to other layers, including common types and infrastructure layers
EasyMemo.Domain: contains the types of domain models and their extension methods
EasyMemo.Repositories: repository implementation library that provides type definitions and implementations related to domain model object warehousing
EasyMemo.Services: an ASP.NET Web API application that provides RESTful services to the outside world. In the "New Project" dialog, select the [Visual C #-> Web] category, select "ASP.NET Web Application" in the category, select "Empty" in the pop-up "New ASP.NET Project" dialog box, and select Web API in the "add folders and core references for the following objects" group:
The home page of EasyMemo.Web:EasyMemo, which provides users with an operating interface, receives user requests, and forwards the requests to the RESTful service. In the "New Project" dialog, select the "Visual C #-> Web" category, select "ASP.NET Web Application" in the category, and select "MVC" in the pop-up "New ASP.NET Project" dialog box:
After creation, EasyMemo's solution should contain the following five projects, each containing only the default type that comes with the Visual Studio project template:
In order to have Visual Studio automatically download the NuGet packages that each project depends on when compiling the entire solution, it is strongly recommended that you right-click the EasyMemo solution and select the enable NuGet package restore option:
Now, we will start with the design of the domain model and complete the development of the entire application step by step.
The first step towards domain modeling
First, right-click on the EasyMemo.Domain project, select manage NuGet packages, enter the keyword [Apworks] in the search online text box of the pop-up dialog box, then select [Apworks] in the package list and click the "install" button:
The license agreement dialog box will be prompted during installation, and click the "I accept" button.
Then, add a new AggregateRoot abstract class to EasyMemo.Domain to implement the IAggregateRoot interface in Apworks:
?
1234567using System; using Apworks; public abstract class AggregateRoot: IAggregateRoot {public Guid ID {get; set;}}
Create a new Account class to inherit the AggregateRoot class, which represents the concept of "user account" in the entire EasyMemo application. For a more convenient and quick implementation, the Account class provides only the following properties:
?
1234567891011121314151617181920212232426272829303132333435 / the concept of "user account" in EasyMemo / / public class Account: AggregateRoot {/ get or set the account name. / public string Name {get; set;} / get or set the account password. / public string Password {get; set;} / get or set the email address. / public string Email {get; set;} / gets or sets the display name. / public string DisplayName {get; set;} / get or set the account creation date. / public DateTime DateCreated {get; set;} / gets or sets the last login date. / public DateTime? DateLastLogon {get; set;}}
Compiling the EasyMemo.Domain, which is successful, means that we have installed and referenced the Apworks package normally, and we can continue to design the domain model.
On how to use Visual Studio to develop applications for classic hierarchical architecture to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.