Dependency injection (DI) is a technology to realize loose coupling between objects and their partners or dependencies. Instead of instantiating the author directly or using static references, provide the object used to perform the action to the class in some way. Typically, classes declare their dependencies through their constructors, allowing them to follow the explicit Dependencies Principle, a method known as "constructor injection.".

Using the idea of DI in the design of class will make their dependencies more coupling, because they have no direct hard coding dependence on their partners. They follow the Dependency Inversion Principle "high-level modules should not rely on low-level modules, and both should rely on abstraction " Class is required to provide abstractions (usually interfaces) to them when they are constructed, rather than directly referring to specific implementations. Extracting the dependencies of interfaces and providing their implementation as parameters is also an example of Strategy design pattern.

Principle of dependency injection

//Contract an abstract interface
public interface IRepository
{
    string GetInfo();
}

//Using EF to implement the interface
public class EFRepository : IRepository
{
    public string GetInfo()
    {
        return "load data form ef!";
    }
}

//Using dapper to implement the interface
public class DapperRepository : IRepository
{
    public string GetInfo()
    {
        return "load data form dapper!";
    }
}

//Provides an abstract interface in the constructor of the service used to perform the operation
public class OperationService
{
    private readonly IRepository _repository;
    public OperationService(IRepository repository)
    {
        _repository = repository;
    }

    public string GetList()
    {
        return _repository.GetInfo();
    }
}   

From the above code, it can be seen that there is no strong dependency between service and repository, but both of them are related to the abstract interface irepository.

Middleware is used to configure the request pipeline to the web application to process the request and the corresponding.

We can configure request delegation through three extension methods Run, Map, and Use. You can specify a single request delegate as an anonymous inline method, or as a definition in a reusable class. These reusable classes or anonymous methods are called middleware.

I've heard about .Net core for a long time, but I just have time to learn and touch recently. As a part of .Net core, asp.net core can develop and run cross platform web applications on windows, MAC and Linux. Asp.net core is a significant reconstruction of asp.net. Due to the change of architecture, it is no longer based on system.web.dll. It has become a more compact and modular framework that can run on. Net core and complete. Net framework.

Microsoft official quick start tutorial:Get started with .NET in 10 minutes ,It contains the download address of the .Net core SDK。

After installation, you can view the version and help from the command prompt

//View version
dotnet --version

//View help
dotnet --help

//View template packages included in the initialization project help and framework
dotnet new --help

If you use visual studio 2017.3 preview and above, you can quickly experience the construction of development environment.

Install the Vue simple scaffold and initialize the project

For the development of Vue components, I usually use webpack as the loading / packaging tool for the previous resources. In order to achieve the goal of rapid development, Vue official also made a scaffold for webpack. We only need a little modification of the scaffold to complete the preparation before developing components.

//Installing the Vue scaffold
npm install -g vue-cli

//Initializing a simple Vue project with a scaffold
vue init webpack-simple vue-test

//Initialize project
cd vue-test
npm i

//Run view project
npm run dev