(1) Getting started with MasaFramework tutorial

(1) Getting started with MasaFramework tutorial

Let's first understand what MasaFramework is

最后更新 3/16/2023 10:50 PM
token的技术分享
预计阅读 4 分钟
分类
.NET
标签
.NET C# MASA Framework

Let's first understand what MasaFramework is?

MasaFramework is a back-end framework based on. Net 6.0 that can be used to develop Web applications, WPF projects, and console projects.

In fact, the MasaFramework provides many functional packages, which are very powerful and have very good support for Dapr. If anyone wants to try Dapr, you can try the MasaFramework.

Then we started using the MasaFramework and went into actual combat

  1. Install MasaFramework project template
dotnet new install Masa.Template

This installation was successful:

  1. create a project

Open a directory, open the console to create a template project, and create an mfDemo project template

dotnet new masafx --name mfDemo

The creation is complete and the solution is opened

  1. Project structure analysis

We can see the project structure after opening the solution.

项目区分src/ApiGatewayssrc/Contractssrc/Servicessrc/Web四层,这个时候可能就会有很多人有疑惑了,为什么跟传统的 Abp 架构设计有些差异,其实这个就是 MasaFramework 的框架美妙之处。

src/ApiGateways中包含对外使用的接口实现(站长注:客户端接口调用的封装),相当于我可以直接将src/ApiGatewayssrc/Web的前端项目使用,这样的好处就是减少前端项目的依赖性,并且利于接口的快速对接。

src/Contracts中包含了基本的模型,和一些共享的东西,src/Contracts是纯粹的,没有任何依赖,所以src/ApiGatewayssrc/Services都会直接依赖src/Contracts,用于共享 Model 或其他东西。

src/Services中就是包含了具体业务和实现,并且包含Host,在Application中包含业务处理或事件处理:

If you are not using MiniApi, what should appear are Controllers:

In fact, it is recommended to use MiniApi because the two implementation methods are different, which makes MiniApi better in performance than Controllers.

Infrastructure is the infrastructure of the project. Looking at the picture, we find that Entity, Middleware, Repository, and DbContext are all in the infrastructure:

The design of MasaFramework is to simplify the complexity of the project and integrate it into one project. If you have just used MasaFramework, never split it up. If you split it up, it will not be consistent with the design of the MasaFramework itself. But if you are a skilled boss, forget I said anything, just started MasaFramework, please use the design of your own framework.

src/Web就是我们的实际的前端项目了。

创建的默认的模板提供是 Blazor Server 模式的项目,可以自行拆分成三层项目mfDemo.SharedmfDemo.ServermfDemo.WebAssembly三层项目架构。

mfDemo.Shared can be understood as all functions such as project implementation and interface file organization.

mfDemon.Server is actually a shell of Blazor Server used to host the mfDemon.Shared project.

mfDemon.WebAssembly is actually a shell of Blazor WebAssembly, used to host the mfDemon.Shared project.

This way our project can support both Blazor Server and Blazor WebAssembly models,

end

Through the above, we can basically understand the project structure of MasaFramework and understand the design of MasaFramework.

This is the first introduction to MasaFramework. I will continue to learn MasaFramework and share it with you.

Sharing from token

MASA Framework

Study exchange: 737776595

Keep Exploring

延伸阅读

更多文章
同分类 / 同标签 4/22/2026

Support for. NET by operating system versions (250707 update)

Use virtual machines and test machines to test the support of each version of the operating system for. NET. After installing the operating system, it is passed by measuring the corresponding running time of the installation and being able to run the Stardust Agent.

继续阅读