` 标签:
+
+```html
+
+
+
+
+
+ {%{{{ "::Actions" | abpLocalization }}}%}
+ {%{{{ "::Name" | abpLocalization }}}%}
+ {%{{{ "::Type" | abpLocalization }}}%}
+ {%{{{ "::PublishDate" | abpLocalization }}}%}
+ {%{{{ "::Price" | abpLocalization }}}%}
+
+
+
+
+
+
+
+ {%{{{ "::Actions" | abpLocalization }}}%}
+
+
+
+ {%{{{ "::Edit" | abpLocalization }}}%}
+
+
+
+
+ {%{{{ data.name }}}%}
+ {%{{{ booksType[data.type] }}}%}
+ {%{{{ data.publishDate | date }}}%}
+ {%{{{ data.price }}}%}
+
+
+
+```
+
+- 我们添加了 "Actions" 栏的 `th`.
+- 我们添加了带有 `ngbDropdownToggle` 的 `button`,在点击按钮时打开操作.
+- 我们习惯于将[NgbDropdown](https://ng-bootstrap.github.io/#/components/dropdown/examples)用于操作的下拉菜单.
+
+UI最终看起来像这样:
+
+
+
+打开 `app\books\book-list` 文件夹下的 `book-list.component.html` 文件,使用以下内容替换 `
` 标签:
+
+```html
+
+ {%{{{ (selectedBook.id ? 'AbpIdentity::Edit' : '::NewBook' ) | abpLocalization }}}%}
+
+```
+
+* **Edit** 文本做为编辑记录操作的标题, **New Book** 做为添加记录操作的标题.
+
+### 删除图书
+
+#### DeleteBook 动作
+
+打开 `books\state` 文件夹下的 `books.actions.ts` 文件添加名为 `DeleteBook` 的动作.
+
+```js
+export class DeleteBook {
+ static readonly type = '[Books] Delete';
+ constructor(public id: string) {}
+}
+```
+
+打开 `books\state` 文件夹下的 `books.state.ts` 文件,使用以下内容替换它:
+
+```js
+import { PagedResultDto } from '@abp/ng.core';
+import { State, Action, StateContext, Selector } from '@ngxs/store';
+import { GetBooks, CreateUpdateBook, DeleteBook } from './books.actions'; // <== added DeleteBook==>
+import { BookService } from '../../app/shared/services';
+import { tap } from 'rxjs/operators';
+import { Injectable } from '@angular/core';
+import { BookDto } from '../../app/shared/models';
+
+export class BooksStateModel {
+ public book: PagedResultDto;
+}
+
+@State({
+ name: 'BooksState',
+ defaults: { book: {} } as BooksStateModel,
+})
+@Injectable()
+export class BooksState {
+ @Selector()
+ static getBooks(state: BooksStateModel) {
+ return state.book.items || [];
+ }
+
+ constructor(private bookService: BookService) {}
+
+ @Action(GetBooks)
+ get(ctx: StateContext) {
+ return this.bookService.getListByInput().pipe(
+ tap((booksResponse) => {
+ ctx.patchState({
+ book: booksResponse,
+ });
+ })
+ );
+ }
+
+ @Action(CreateUpdateBook)
+ save(ctx: StateContext, action: CreateUpdateBook) {
+ if (action.id) {
+ return this.bookService.updateByIdAndInput(action.payload, action.id);
+ } else {
+ return this.bookService.createByInput(action.payload);
+ }
+ }
+
+ // <== added DeleteBook action listener ==>
+ @Action(DeleteBook)
+ delete(ctx: StateContext, action: DeleteBook) {
+ return this.bookService.deleteById(action.id);
+ }
+}
+```
+
+- 我们导入了 `DeleteBook` .
+
+- 我们在文件末尾添加了 `DeleteBook` 动作监听器.
+
+#### 删除确认弹层
+
+打开 `app\books\book-list` 文件夹下的 `book-list.component.ts` 文件,注入 `ConfirmationService`.
+
+替换构造函数:
+
+```js
+import { ConfirmationService } from '@abp/ng.theme.shared';
+//...
+
+constructor(
+ private store: Store,
+ private fb: FormBuilder,
+ private bookService: BookService,
+ private confirmation: ConfirmationService // <== added this line ==>
+) { }
+```
+
+* 我们导入了 `ConfirmationService`.
+* 我们在构造函数注入了 `ConfirmationService` .
+
+参阅[确认弹层文档](https://docs.abp.io/en/abp/latest/UI/Angular/Confirmation-Service)了解更多
+
+在 `book-list.component.ts` 中添加删除方法:
+
+```js
+import { GetBooks, CreateUpdateBook, DeleteBook } from '../state/books.actions' ;// <== imported DeleteBook ==>
+
+import { ConfirmationService, Confirmation } from '@abp/ng.theme.shared'; //<== imported Confirmation ==>
+
+//...
+
+delete(id: string) {
+ this.confirmation
+ .warn('::AreYouSureToDelete', 'AbpAccount::AreYouSure')
+ .subscribe(status => {
+ if (status === Confirmation.Status.confirm) {
+ this.store.dispatch(new DeleteBook(id)).subscribe(() => this.get());
+ }
+ });
+}
+```
+
+`delete` 方法会显示一个确认弹层并订阅用户响应. 只在用户点击 `Yes` 按钮时分派动作. 确认弹层看起来如下:
+
+
+
+#### 添加删除按钮
+
+打开 `app\books\book-list` 文件夹下的 `app\books\book-list` 文件,修改 `ngbDropdownMenu` 添加删除按钮:
+
+```html
+
+
+
+ {%{{{ 'AbpAccount::Delete' | abpLocalization }}}%}
+
+
+```
+
+最终操作下拉框UI看起来如下:
+
+
+
+{{end}}
+
+### 下一章
+
+查看本教程的 [下一章](Part-3.md) .
diff --git a/docs/zh-Hans/Tutorials/Part-3.md b/docs/zh-Hans/Tutorials/Part-3.md
new file mode 100644
index 0000000000..cded954e6b
--- /dev/null
+++ b/docs/zh-Hans/Tutorials/Part-3.md
@@ -0,0 +1,198 @@
+## ASP.NET Core {{UI_Value}} 教程 - 第三章
+````json
+//[doc-params]
+{
+ "UI": ["MVC","NG"]
+}
+````
+
+{{
+if UI == "MVC"
+ DB="ef"
+ DB_Text="Entity Framework Core"
+ UI_Text="mvc"
+else if UI == "NG"
+ DB="mongodb"
+ DB_Text="MongoDB"
+ UI_Text="angular"
+else
+ DB ="?"
+ UI_Text="?"
+end
+}}
+
+### 关于本教程
+
+这是ASP.NET Core{{UI_Value}}系列教程的第二章. 共有三章:
+
+- [Part-1: 创建项目和书籍列表页面](Part-1.md)
+- [Part 2: 创建,编辑,删除书籍](Part-2.md)
+- **Part-3: 集成测试(本章)**
+
+> 你也可以观看由ABP社区成员为本教程录制的[视频课程](https://amazingsolutions.teachable.com/p/lets-build-the-bookstore-application).
+
+### 解决方案中的测试项目
+
+解决方案中有多个测试项目:
+
+
+
+每个项目用于测试相关的应用程序项目.测试项目使用以下库进行测试:
+
+* [xunit](https://xunit.github.io/) 作为主测试框架.
+* [Shoudly](http://shouldly.readthedocs.io/en/latest/) 作为断言库.
+* [NSubstitute](http://nsubstitute.github.io/) 作为模拟库.
+
+### 添加测试数据
+
+启动模板包含`Acme.BookStore.TestBase`项目中的`BookStoreTestDataSeedContributor`类,它创建一些数据来运行测试.
+更改`BookStoreTestDataSeedContributor`类如下所示:
+
+````csharp
+using System;
+using System.Threading.Tasks;
+using Volo.Abp.Data;
+using Volo.Abp.DependencyInjection;
+using Volo.Abp.Domain.Repositories;
+using Volo.Abp.Guids;
+
+namespace Acme.BookStore
+{
+ public class BookStoreTestDataSeedContributor
+ : IDataSeedContributor, ITransientDependency
+ {
+ private readonly IRepository _bookRepository;
+ private readonly IGuidGenerator _guidGenerator;
+
+ public BookStoreTestDataSeedContributor(
+ IRepository bookRepository,
+ IGuidGenerator guidGenerator)
+ {
+ _bookRepository = bookRepository;
+ _guidGenerator = guidGenerator;
+ }
+
+ public async Task SeedAsync(DataSeedContext context)
+ {
+ await _bookRepository.InsertAsync(
+ new Book(id: _guidGenerator.Create(),
+ name: "Test book 1",
+ type: BookType.Fantastic,
+ publishDate: new DateTime(2015, 05, 24),
+ price: 21
+ )
+ );
+
+ await _bookRepository.InsertAsync(
+ new Book(id: _guidGenerator.Create(),
+ name: "Test book 2",
+ type: BookType.Science,
+ publishDate: new DateTime(2014, 02, 11),
+ price: 15
+ )
+ );
+ }
+ }
+}
+````
+
+* 注入`IRepository`并在`SeedAsync`中使用它来创建两个书实体作为测试数据.
+* 使用`IGuidGenerator`服务创建GUID. 虽然`Guid.NewGuid()`非常适合测试,但`IGuidGenerator`在使用真实数据库时还有其他特别重要的功能(参见[Guid生成文档](../Guid-Generation.md)了解更多信息).
+
+### 测试 BookAppService
+
+在 `Acme.BookStore.Application.Tests` 项目中创建一个名叫 `BookAppService_Tests` 的测试类:
+
+````csharp
+using System;
+using System.Linq;
+using System.Threading.Tasks;
+using Xunit;
+using Shouldly;
+using Volo.Abp.Application.Dtos;
+using Volo.Abp.Validation;
+using Microsoft.EntityFrameworkCore.Internal;
+
+namespace Acme.BookStore
+{
+ public class BookAppService_Tests : BookStoreApplicationTestBase
+ {
+ private readonly IBookAppService _bookAppService;
+
+ public BookAppService_Tests()
+ {
+ _bookAppService = GetRequiredService();
+ }
+
+ [Fact]
+ public async Task Should_Get_List_Of_Books()
+ {
+ //Act
+ var result = await _bookAppService.GetListAsync(
+ new PagedAndSortedResultRequestDto()
+ );
+
+ //Assert
+ result.TotalCount.ShouldBeGreaterThan(0);
+ result.Items.ShouldContain(b => b.Name == "Test book 1");
+ }
+ }
+}
+````
+
+* 测试方法 `Should_Get_List_Of_Books` 直接使用 `BookAppService.GetListAsync` 方法来获取用户列表,并执行检查.
+
+新增测试方法,用以测试创建一个合法book实体的场景:
+
+````C#
+[Fact]
+public async Task Should_Create_A_Valid_Book()
+{
+ //Act
+ var result = await _bookAppService.CreateAsync(
+ new CreateUpdateBookDto
+ {
+ Name = "New test book 42",
+ Price = 10,
+ PublishDate = DateTime.Now,
+ Type = BookType.ScienceFiction
+ }
+ );
+
+ //Assert
+ result.Id.ShouldNotBe(Guid.Empty);
+ result.Name.ShouldBe("New test book 42");
+}
+````
+
+新增测试方法,用以测试创建一个非法book实体失败的场景:
+
+````csharp
+[Fact]
+public async Task Should_Not_Create_A_Book_Without_Name()
+{
+ var exception = await Assert.ThrowsAsync(async () =>
+ {
+ await _bookAppService.CreateAsync(
+ new CreateUpdateBookDto
+ {
+ Name = "",
+ Price = 10,
+ PublishDate = DateTime.Now,
+ Type = BookType.ScienceFiction
+ }
+ );
+ });
+
+ exception.ValidationErrors
+ .ShouldContain(err => err.MemberNames.Any(mem => mem == "Name"));
+}
+````
+
+* 由于 `Name` 是空值, ABP 抛出一个 `AbpValidationException` 异常.
+
+打开**测试资源管理器**(测试 -> Windows -> 测试资源管理器)并**执行**所有测试:
+
+
+
+恭喜, 绿色图标表示测试已成功通过!
diff --git a/docs/zh-Hans/Tutorials/images/bookstore-actions-buttons.png b/docs/zh-Hans/Tutorials/images/bookstore-actions-buttons.png
new file mode 100644
index 0000000000..e8243fedc7
Binary files /dev/null and b/docs/zh-Hans/Tutorials/images/bookstore-actions-buttons.png differ
diff --git a/docs/zh-Hans/Tutorials/AspNetCore-Mvc/images/bookstore-add-create-dialog-v2.png b/docs/zh-Hans/Tutorials/images/bookstore-add-create-dialog-v2.png
similarity index 100%
rename from docs/zh-Hans/Tutorials/AspNetCore-Mvc/images/bookstore-add-create-dialog-v2.png
rename to docs/zh-Hans/Tutorials/images/bookstore-add-create-dialog-v2.png
diff --git a/docs/zh-Hans/Tutorials/AspNetCore-Mvc/images/bookstore-add-edit-dialog.png b/docs/zh-Hans/Tutorials/images/bookstore-add-edit-dialog.png
similarity index 100%
rename from docs/zh-Hans/Tutorials/AspNetCore-Mvc/images/bookstore-add-edit-dialog.png
rename to docs/zh-Hans/Tutorials/images/bookstore-add-edit-dialog.png
diff --git a/docs/zh-Hans/Tutorials/AspNetCore-Mvc/images/bookstore-add-index-page-v2.png b/docs/zh-Hans/Tutorials/images/bookstore-add-index-page-v2.png
similarity index 100%
rename from docs/zh-Hans/Tutorials/AspNetCore-Mvc/images/bookstore-add-index-page-v2.png
rename to docs/zh-Hans/Tutorials/images/bookstore-add-index-page-v2.png
diff --git a/docs/zh-Hans/Tutorials/images/bookstore-angular-file-tree.png b/docs/zh-Hans/Tutorials/images/bookstore-angular-file-tree.png
new file mode 100644
index 0000000000..a3197b6457
Binary files /dev/null and b/docs/zh-Hans/Tutorials/images/bookstore-angular-file-tree.png differ
diff --git a/docs/zh-Hans/Tutorials/AspNetCore-Mvc/images/bookstore-appservice-tests.png b/docs/zh-Hans/Tutorials/images/bookstore-appservice-tests.png
similarity index 100%
rename from docs/zh-Hans/Tutorials/AspNetCore-Mvc/images/bookstore-appservice-tests.png
rename to docs/zh-Hans/Tutorials/images/bookstore-appservice-tests.png
diff --git a/docs/zh-Hans/Tutorials/images/bookstore-book-list-2.png b/docs/zh-Hans/Tutorials/images/bookstore-book-list-2.png
new file mode 100644
index 0000000000..a460d4241b
Binary files /dev/null and b/docs/zh-Hans/Tutorials/images/bookstore-book-list-2.png differ
diff --git a/docs/zh-Hans/Tutorials/images/bookstore-book-list.png b/docs/zh-Hans/Tutorials/images/bookstore-book-list.png
new file mode 100644
index 0000000000..9e6cc9e010
Binary files /dev/null and b/docs/zh-Hans/Tutorials/images/bookstore-book-list.png differ
diff --git a/docs/zh-Hans/Tutorials/AspNetCore-Mvc/images/bookstore-books-table-actions.png b/docs/zh-Hans/Tutorials/images/bookstore-books-table-actions.png
similarity index 100%
rename from docs/zh-Hans/Tutorials/AspNetCore-Mvc/images/bookstore-books-table-actions.png
rename to docs/zh-Hans/Tutorials/images/bookstore-books-table-actions.png
diff --git a/docs/zh-Hans/Tutorials/AspNetCore-Mvc/images/bookstore-books-table.png b/docs/zh-Hans/Tutorials/images/bookstore-books-table.png
similarity index 100%
rename from docs/zh-Hans/Tutorials/AspNetCore-Mvc/images/bookstore-books-table.png
rename to docs/zh-Hans/Tutorials/images/bookstore-books-table.png
diff --git a/docs/zh-Hans/Tutorials/images/bookstore-confirmation-popup.png b/docs/zh-Hans/Tutorials/images/bookstore-confirmation-popup.png
new file mode 100644
index 0000000000..a80b180f1c
Binary files /dev/null and b/docs/zh-Hans/Tutorials/images/bookstore-confirmation-popup.png differ
diff --git a/docs/zh-Hans/Tutorials/AspNetCore-Mvc/images/bookstore-create-dialog-2.png b/docs/zh-Hans/Tutorials/images/bookstore-create-dialog-2.png
similarity index 100%
rename from docs/zh-Hans/Tutorials/AspNetCore-Mvc/images/bookstore-create-dialog-2.png
rename to docs/zh-Hans/Tutorials/images/bookstore-create-dialog-2.png
diff --git a/docs/zh-Hans/Tutorials/AspNetCore-Mvc/images/bookstore-create-dialog.png b/docs/zh-Hans/Tutorials/images/bookstore-create-dialog.png
similarity index 100%
rename from docs/zh-Hans/Tutorials/AspNetCore-Mvc/images/bookstore-create-dialog.png
rename to docs/zh-Hans/Tutorials/images/bookstore-create-dialog.png
diff --git a/docs/zh-Hans/Tutorials/images/bookstore-create-project-angular.png b/docs/zh-Hans/Tutorials/images/bookstore-create-project-angular.png
new file mode 100644
index 0000000000..b9eb38b8b7
Binary files /dev/null and b/docs/zh-Hans/Tutorials/images/bookstore-create-project-angular.png differ
diff --git a/docs/zh-Hans/Tutorials/images/bookstore-create-project-mvc.png b/docs/zh-Hans/Tutorials/images/bookstore-create-project-mvc.png
new file mode 100644
index 0000000000..f453b20279
Binary files /dev/null and b/docs/zh-Hans/Tutorials/images/bookstore-create-project-mvc.png differ
diff --git a/docs/zh-Hans/Tutorials/images/bookstore-creating-book-list-terminal.png b/docs/zh-Hans/Tutorials/images/bookstore-creating-book-list-terminal.png
new file mode 100644
index 0000000000..6f19dcc7bf
Binary files /dev/null and b/docs/zh-Hans/Tutorials/images/bookstore-creating-book-list-terminal.png differ
diff --git a/docs/zh-Hans/Tutorials/images/bookstore-creating-books-module-terminal.png b/docs/zh-Hans/Tutorials/images/bookstore-creating-books-module-terminal.png
new file mode 100644
index 0000000000..ec9ef4c42f
Binary files /dev/null and b/docs/zh-Hans/Tutorials/images/bookstore-creating-books-module-terminal.png differ
diff --git a/docs/zh-Hans/Tutorials/images/bookstore-database-tables-ef.png b/docs/zh-Hans/Tutorials/images/bookstore-database-tables-ef.png
new file mode 100644
index 0000000000..857b10de5b
Binary files /dev/null and b/docs/zh-Hans/Tutorials/images/bookstore-database-tables-ef.png differ
diff --git a/docs/zh-Hans/Tutorials/images/bookstore-database-tables-mongodb.png b/docs/zh-Hans/Tutorials/images/bookstore-database-tables-mongodb.png
new file mode 100644
index 0000000000..8d78bd9a54
Binary files /dev/null and b/docs/zh-Hans/Tutorials/images/bookstore-database-tables-mongodb.png differ
diff --git a/docs/zh-Hans/Tutorials/images/bookstore-edit-button.png b/docs/zh-Hans/Tutorials/images/bookstore-edit-button.png
new file mode 100644
index 0000000000..bfc1c64797
Binary files /dev/null and b/docs/zh-Hans/Tutorials/images/bookstore-edit-button.png differ
diff --git a/docs/zh-Hans/Tutorials/images/bookstore-empty-new-book-modal.png b/docs/zh-Hans/Tutorials/images/bookstore-empty-new-book-modal.png
new file mode 100644
index 0000000000..2a02802bb9
Binary files /dev/null and b/docs/zh-Hans/Tutorials/images/bookstore-empty-new-book-modal.png differ
diff --git a/docs/zh-Hans/Tutorials/images/bookstore-final-actions-dropdown.png b/docs/zh-Hans/Tutorials/images/bookstore-final-actions-dropdown.png
new file mode 100644
index 0000000000..4f41829f0d
Binary files /dev/null and b/docs/zh-Hans/Tutorials/images/bookstore-final-actions-dropdown.png differ
diff --git a/docs/zh-Hans/Tutorials/images/bookstore-generate-state-books.png b/docs/zh-Hans/Tutorials/images/bookstore-generate-state-books.png
new file mode 100644
index 0000000000..be7a919017
Binary files /dev/null and b/docs/zh-Hans/Tutorials/images/bookstore-generate-state-books.png differ
diff --git a/docs/zh-Hans/Tutorials/AspNetCore-Mvc/images/bookstore-homepage.png b/docs/zh-Hans/Tutorials/images/bookstore-homepage.png
similarity index 100%
rename from docs/zh-Hans/Tutorials/AspNetCore-Mvc/images/bookstore-homepage.png
rename to docs/zh-Hans/Tutorials/images/bookstore-homepage.png
diff --git a/docs/zh-Hans/Tutorials/AspNetCore-Mvc/images/bookstore-index-js-file-v2.png b/docs/zh-Hans/Tutorials/images/bookstore-index-js-file-v2.png
similarity index 100%
rename from docs/zh-Hans/Tutorials/AspNetCore-Mvc/images/bookstore-index-js-file-v2.png
rename to docs/zh-Hans/Tutorials/images/bookstore-index-js-file-v2.png
diff --git a/docs/zh-Hans/Tutorials/images/bookstore-initial-book-list-page.png b/docs/zh-Hans/Tutorials/images/bookstore-initial-book-list-page.png
new file mode 100644
index 0000000000..591cffb121
Binary files /dev/null and b/docs/zh-Hans/Tutorials/images/bookstore-initial-book-list-page.png differ
diff --git a/docs/zh-Hans/Tutorials/images/bookstore-initial-books-page-with-layout.png b/docs/zh-Hans/Tutorials/images/bookstore-initial-books-page-with-layout.png
new file mode 100644
index 0000000000..629ad46444
Binary files /dev/null and b/docs/zh-Hans/Tutorials/images/bookstore-initial-books-page-with-layout.png differ
diff --git a/docs/zh-Hans/Tutorials/images/bookstore-localization-files-v2.png b/docs/zh-Hans/Tutorials/images/bookstore-localization-files-v2.png
new file mode 100644
index 0000000000..542cda209c
Binary files /dev/null and b/docs/zh-Hans/Tutorials/images/bookstore-localization-files-v2.png differ
diff --git a/docs/zh-Hans/Tutorials/AspNetCore-Mvc/images/bookstore-menu-items.png b/docs/zh-Hans/Tutorials/images/bookstore-menu-items.png
similarity index 100%
rename from docs/zh-Hans/Tutorials/AspNetCore-Mvc/images/bookstore-menu-items.png
rename to docs/zh-Hans/Tutorials/images/bookstore-menu-items.png
diff --git a/docs/zh-Hans/Tutorials/images/bookstore-migrations-applied-angular.png b/docs/zh-Hans/Tutorials/images/bookstore-migrations-applied-angular.png
new file mode 100644
index 0000000000..0724e4ae8f
Binary files /dev/null and b/docs/zh-Hans/Tutorials/images/bookstore-migrations-applied-angular.png differ
diff --git a/docs/zh-Hans/Tutorials/images/bookstore-migrations-applied-mvc.png b/docs/zh-Hans/Tutorials/images/bookstore-migrations-applied-mvc.png
new file mode 100644
index 0000000000..d59c0ce1d3
Binary files /dev/null and b/docs/zh-Hans/Tutorials/images/bookstore-migrations-applied-mvc.png differ
diff --git a/docs/zh-Hans/Tutorials/images/bookstore-new-book-button.png b/docs/zh-Hans/Tutorials/images/bookstore-new-book-button.png
new file mode 100644
index 0000000000..8112fe1352
Binary files /dev/null and b/docs/zh-Hans/Tutorials/images/bookstore-new-book-button.png differ
diff --git a/docs/zh-Hans/Tutorials/images/bookstore-new-book-form-v2.png b/docs/zh-Hans/Tutorials/images/bookstore-new-book-form-v2.png
new file mode 100644
index 0000000000..72513de6e5
Binary files /dev/null and b/docs/zh-Hans/Tutorials/images/bookstore-new-book-form-v2.png differ
diff --git a/docs/zh-Hans/Tutorials/images/bookstore-new-book-form.png b/docs/zh-Hans/Tutorials/images/bookstore-new-book-form.png
new file mode 100644
index 0000000000..95de64f8d4
Binary files /dev/null and b/docs/zh-Hans/Tutorials/images/bookstore-new-book-form.png differ
diff --git a/docs/zh-Hans/Tutorials/images/bookstore-new-menu-item.png b/docs/zh-Hans/Tutorials/images/bookstore-new-menu-item.png
new file mode 100644
index 0000000000..97bf7fc7c1
Binary files /dev/null and b/docs/zh-Hans/Tutorials/images/bookstore-new-menu-item.png differ
diff --git a/docs/zh-Hans/Tutorials/images/bookstore-open-package-manager-console.png b/docs/zh-Hans/Tutorials/images/bookstore-open-package-manager-console.png
new file mode 100644
index 0000000000..a640eb2681
Binary files /dev/null and b/docs/zh-Hans/Tutorials/images/bookstore-open-package-manager-console.png differ
diff --git a/docs/zh-Hans/Tutorials/images/bookstore-pmc-add-book-migration-v2.png b/docs/zh-Hans/Tutorials/images/bookstore-pmc-add-book-migration-v2.png
new file mode 100644
index 0000000000..2baea20236
Binary files /dev/null and b/docs/zh-Hans/Tutorials/images/bookstore-pmc-add-book-migration-v2.png differ
diff --git a/docs/zh-Hans/Tutorials/AspNetCore-Mvc/images/bookstore-pmc-add-book-migration.png b/docs/zh-Hans/Tutorials/images/bookstore-pmc-add-book-migration.png
similarity index 100%
rename from docs/zh-Hans/Tutorials/AspNetCore-Mvc/images/bookstore-pmc-add-book-migration.png
rename to docs/zh-Hans/Tutorials/images/bookstore-pmc-add-book-migration.png
diff --git a/docs/zh-Hans/Tutorials/images/bookstore-service-terminal-output.png b/docs/zh-Hans/Tutorials/images/bookstore-service-terminal-output.png
new file mode 100644
index 0000000000..cf6145e03f
Binary files /dev/null and b/docs/zh-Hans/Tutorials/images/bookstore-service-terminal-output.png differ
diff --git a/docs/zh-Hans/Tutorials/images/bookstore-solution-structure-angular.png b/docs/zh-Hans/Tutorials/images/bookstore-solution-structure-angular.png
new file mode 100644
index 0000000000..07d064a880
Binary files /dev/null and b/docs/zh-Hans/Tutorials/images/bookstore-solution-structure-angular.png differ
diff --git a/docs/zh-Hans/Tutorials/AspNetCore-Mvc/images/bookstore-visual-studio-solution-v3.png b/docs/zh-Hans/Tutorials/images/bookstore-solution-structure-mvc.png
similarity index 100%
rename from docs/zh-Hans/Tutorials/AspNetCore-Mvc/images/bookstore-visual-studio-solution-v3.png
rename to docs/zh-Hans/Tutorials/images/bookstore-solution-structure-mvc.png
diff --git a/docs/zh-Hans/Tutorials/images/bookstore-start-project-angular.png b/docs/zh-Hans/Tutorials/images/bookstore-start-project-angular.png
new file mode 100644
index 0000000000..08abf845a8
Binary files /dev/null and b/docs/zh-Hans/Tutorials/images/bookstore-start-project-angular.png differ
diff --git a/docs/zh-Hans/Tutorials/images/bookstore-start-project-mvc.png b/docs/zh-Hans/Tutorials/images/bookstore-start-project-mvc.png
new file mode 100644
index 0000000000..133dc6f131
Binary files /dev/null and b/docs/zh-Hans/Tutorials/images/bookstore-start-project-mvc.png differ
diff --git a/docs/zh-Hans/Tutorials/images/bookstore-swagger-book-dto-properties.png b/docs/zh-Hans/Tutorials/images/bookstore-swagger-book-dto-properties.png
new file mode 100644
index 0000000000..66d630bb56
Binary files /dev/null and b/docs/zh-Hans/Tutorials/images/bookstore-swagger-book-dto-properties.png differ
diff --git a/docs/zh-Hans/Tutorials/images/bookstore-swagger.png b/docs/zh-Hans/Tutorials/images/bookstore-swagger.png
new file mode 100644
index 0000000000..3ce36a11bc
Binary files /dev/null and b/docs/zh-Hans/Tutorials/images/bookstore-swagger.png differ
diff --git a/docs/zh-Hans/Tutorials/AspNetCore-Mvc/images/bookstore-test-js-proxy-getlist-network.png b/docs/zh-Hans/Tutorials/images/bookstore-test-js-proxy-getlist-network.png
similarity index 100%
rename from docs/zh-Hans/Tutorials/AspNetCore-Mvc/images/bookstore-test-js-proxy-getlist-network.png
rename to docs/zh-Hans/Tutorials/images/bookstore-test-js-proxy-getlist-network.png
diff --git a/docs/zh-Hans/Tutorials/AspNetCore-Mvc/images/bookstore-test-js-proxy-getlist.png b/docs/zh-Hans/Tutorials/images/bookstore-test-js-proxy-getlist.png
similarity index 100%
rename from docs/zh-Hans/Tutorials/AspNetCore-Mvc/images/bookstore-test-js-proxy-getlist.png
rename to docs/zh-Hans/Tutorials/images/bookstore-test-js-proxy-getlist.png
diff --git a/docs/zh-Hans/Tutorials/images/bookstore-test-projects-angular.png b/docs/zh-Hans/Tutorials/images/bookstore-test-projects-angular.png
new file mode 100644
index 0000000000..6a8947238e
Binary files /dev/null and b/docs/zh-Hans/Tutorials/images/bookstore-test-projects-angular.png differ
diff --git a/docs/zh-Hans/Tutorials/AspNetCore-Mvc/images/bookstore-test-projects-v2.png b/docs/zh-Hans/Tutorials/images/bookstore-test-projects-mvc.png
similarity index 100%
rename from docs/zh-Hans/Tutorials/AspNetCore-Mvc/images/bookstore-test-projects-v2.png
rename to docs/zh-Hans/Tutorials/images/bookstore-test-projects-mvc.png
diff --git a/docs/zh-Hans/Tutorials/images/bookstore-test-projects-v2.png b/docs/zh-Hans/Tutorials/images/bookstore-test-projects-v2.png
new file mode 100644
index 0000000000..8701164d75
Binary files /dev/null and b/docs/zh-Hans/Tutorials/images/bookstore-test-projects-v2.png differ
diff --git a/docs/zh-Hans/Tutorials/images/bookstore-update-database-after-book-entity.png b/docs/zh-Hans/Tutorials/images/bookstore-update-database-after-book-entity.png
new file mode 100644
index 0000000000..4889f4f757
Binary files /dev/null and b/docs/zh-Hans/Tutorials/images/bookstore-update-database-after-book-entity.png differ
diff --git a/docs/zh-Hans/Tutorials/AspNetCore-Mvc/images/bookstore-user-management.png b/docs/zh-Hans/Tutorials/images/bookstore-user-management.png
similarity index 100%
rename from docs/zh-Hans/Tutorials/AspNetCore-Mvc/images/bookstore-user-management.png
rename to docs/zh-Hans/Tutorials/images/bookstore-user-management.png
diff --git a/docs/zh-Hans/Tutorials/images/bookstore-visual-studio-solution-v3.png b/docs/zh-Hans/Tutorials/images/bookstore-visual-studio-solution-v3.png
new file mode 100644
index 0000000000..307e3516a5
Binary files /dev/null and b/docs/zh-Hans/Tutorials/images/bookstore-visual-studio-solution-v3.png differ
diff --git a/docs/zh-Hans/Tutorials/images/generate-proxy-command.png b/docs/zh-Hans/Tutorials/images/generate-proxy-command.png
new file mode 100644
index 0000000000..f850ce07a2
Binary files /dev/null and b/docs/zh-Hans/Tutorials/images/generate-proxy-command.png differ
diff --git a/docs/zh-Hans/Tutorials/images/generated-proxies.png b/docs/zh-Hans/Tutorials/images/generated-proxies.png
new file mode 100644
index 0000000000..9e466e7d55
Binary files /dev/null and b/docs/zh-Hans/Tutorials/images/generated-proxies.png differ
diff --git a/docs/zh-Hans/Tutorials/images/mozilla-self-signed-cert-error.png b/docs/zh-Hans/Tutorials/images/mozilla-self-signed-cert-error.png
new file mode 100644
index 0000000000..c9e2fc0e65
Binary files /dev/null and b/docs/zh-Hans/Tutorials/images/mozilla-self-signed-cert-error.png differ
diff --git a/docs/zh-Hans/UI/Angular/Config-State.md b/docs/zh-Hans/UI/Angular/Config-State.md
index 4967dd78b3..de645c8968 100644
--- a/docs/zh-Hans/UI/Angular/Config-State.md
+++ b/docs/zh-Hans/UI/Angular/Config-State.md
@@ -236,7 +236,7 @@ const newRoute: ABP.Route = {
path: "page",
invisible: false,
order: 2,
- requiredPolicy: "MyProjectName::MyNewPage"
+ requiredPolicy: "MyProjectName.MyNewPage"
};
this.config.dispatchAddRoute(newRoute);
@@ -248,16 +248,17 @@ this.config.dispatchAddRoute(newRoute);
如果你想要**添加一个子路由,你可以这样做:**
```js
+import { eIdentityRouteNames } from '@abp/ng.identity';
// this.config is instance of ConfigStateService
const newRoute: ABP.Route = {
- parentName: "AbpAccount::Login",
+ parentName: eIdentityRouteNames.IdentityManagement,
name: "My New Page",
iconClass: "fa fa-dashboard",
path: "page",
invisible: false,
order: 2,
- requiredPolicy: "MyProjectName::MyNewPage"
+ requiredPolicy: "MyProjectName.MyNewPage"
};
this.config.dispatchAddRoute(newRoute);
@@ -291,4 +292,4 @@ this.config.dispatchSetEnvironment({
## 下一步是什么?
-* [组件替换](./Component-Replacement.md)
\ No newline at end of file
+- [修改菜单](./Modifying-the-Menu.md)
\ No newline at end of file
diff --git a/docs/zh-Hans/UI/Angular/Confirmation-Service.md b/docs/zh-Hans/UI/Angular/Confirmation-Service.md
new file mode 100644
index 0000000000..a1a181837c
--- /dev/null
+++ b/docs/zh-Hans/UI/Angular/Confirmation-Service.md
@@ -0,0 +1,181 @@
+# 确认弹层
+
+你可以使用@abp/ng.theme.shared包中提供 `ConfirmationService` 放置在你项目的级别来显示确认弹层
+
+## 入门
+
+你不必在模块或组件级别提供 `ConfirmationService`,它已经在**根**级别提供,你可以在你的组件,指令或服务直接注入并使用它.
+
+```js
+import { ConfirmationService } from '@abp/ng.theme.shared';
+
+@Component({
+ /* class metadata here */
+})
+class DemoComponent {
+ constructor(private confirmation: ConfirmationService) {}
+}
+```
+
+## 用法
+
+你可以使用 `ConfirmationService` 的 `success`, `warn`, `error` 和 `info` 方法显示一个确认弹层.
+
+### 如何显示一个确认弹层
+
+```js
+const confirmationStatus$ = this.confirmation.success('Message', 'Title');
+```
+
+- `ConfirmationService` 方法接收三个参数,分别是 `message`, `title`, 和 `options`.
+- `success`, `warn`, `error`, 和 `info` 方法返回一个[RxJS Subject](https://rxjs-dev.firebaseapp.com/guide/subject)监听确认弹层关闭事件. 事件值类型是 [`Confirmation.Status`](https://github.com/abpframework/abp/blob/master/npm/ng-packs/packages/theme-shared/src/lib/models/confirmation.ts#L24)枚举.
+
+### 如何监听关闭事件
+
+你可以订阅确认弹层关闭事件,例:
+
+```js
+import { Confirmation, ConfirmationService } from '@abp/ng.theme.shared';
+
+constructor(private confirmation: ConfirmationService) {}
+
+this.confirmation
+ .warn('::WillBeDeleted', { key: '::AreYouSure', defaultValue: 'Are you sure?' })
+ .subscribe((status: Confirmation.Status) => {
+ // your code here
+ });
+```
+
+- `message` 和 `title` 参数接收字符串,本地化Key或本地化对象. 参阅[本地化文档](./Localization.md)
+- `Confirmation.Status` 是一个枚举,具有三个属性;
+ - `Confirmation.Status.confirm` 是一个关闭事件值,当通过确认按钮关闭弹出窗口时触发此事件.
+ - `Confirmation.Status.reject` 是一个关闭事件值,当通过“取消”按钮关闭弹出窗口时触发此事件.
+ - `Confirmation.Status.dismiss` 是一个关闭事件值,当通过按Escape键关闭弹出窗口时触发此事件.
+
+如果你对确认状态不感兴趣,则不必订阅返回的observable:
+
+```js
+this.confirmation.error('You are not authorized.', 'Error');
+```
+
+### 如何显示具有给定选项的确认弹层
+
+选项可以作为第三个参数传递给`success`, `warn`, `error`, 和 `info` 方法:
+
+```js
+const options: Partial = {
+ hideCancelBtn: false,
+ hideYesBtn: false,
+ cancelText: 'Close',
+ yesText: 'Confirm',
+ messageLocalizationParams: ['Demo'],
+ titleLocalizationParams: [],
+};
+
+this.confirmation.warn(
+ 'AbpIdentity::RoleDeletionConfirmationMessage',
+ 'Are you sure?',
+ options,
+);
+```
+
+- `hideCancelBtn` 选项为 `true` 时隐藏取消按钮. 默认值为 `false`.
+- `hideYesBtn` 选项为 `true` 时隐藏确认按钮. 默认值为 `false`.
+- `cancelText` 是取消按钮的文本,可以传递本地化键或本地化对象. 默认值是 `AbpUi::Cancel`.
+- `yesText` 是确定按钮的文本,可以传递本地化键或本地化对象. 默认值是 `AbpUi::Yes`.
+- `messageLocalizationParams`是用于消息本地化的插值参数.
+- `titleLocalizationParams` 是标题本地化的插值参数.
+
+使用以上选项确认弹层窗口如下所示:
+
+
+
+你可以传递HTML字符串作为标题,消息或按钮文本. 例如:
+
+```js
+const options: Partial = {
+ yesText: ' Yes, delete it',
+};
+
+this.confirmation.warn(
+ `
+ Role Demo will be deleted
+
+ Do you confirm that?
+ `,
+ 'Are you sure? ',
+ options,
+);
+```
+
+由于这些值现在是HTML,因此应该手动处理本地化. 参阅[LocalizationService](./Localization#using-the-localization-service)了解如何实现.
+
+> 注意,Angular会清除所有字符串,并且并非每个HTML字符串都可以使用. 仅显示被Angular视为"安全"的值.
+
+### 如何删除一个确认弹层
+
+打开的确认弹出窗口可以通过 `clear` 方法手动删除:
+
+```js
+this.confirmation.clear();
+```
+
+## API
+
+### success
+
+```js
+success(
+ message: Config.LocalizationParam,
+ title: Config.LocalizationParam,
+ options?: Partial,
+): Observable
+```
+
+> 请参见[`Config.LocalizationParam`类型](https://github.com/abpframework/abp/blob/master/npm/ng-packs/packages/core/src/lib/models/config.ts#L46)和[Confirmation名称空间](https://github.com/abpframework/abp/blob/master/npm/ng-packs/packages/theme-shared/src/lib/models/confirmation.ts)
+
+
+### warn
+
+```js
+warn(
+ message: Config.LocalizationParam,
+ title: Config.LocalizationParam,
+ options?: Partial,
+): Observable
+```
+
+### error
+
+```js
+error(
+ message: Config.LocalizationParam,
+ title: Config.LocalizationParam,
+ options?: Partial,
+): Observable
+```
+
+### info
+
+```js
+info(
+ message: Config.LocalizationParam,
+ title: Config.LocalizationParam,
+ options?: Partial,
+): Observable
+```
+
+### clear
+
+```js
+clear(
+ status: Confirmation.Status = Confirmation.Status.dismiss
+): void
+```
+
+- `status` 参数是确认关闭事件的值.
+
+
+## 下一步是什么?
+
+- [Toast Overlay](./Toaster-Service.md)
diff --git a/docs/zh-Hans/UI/Angular/Modifying-the-Menu.md b/docs/zh-Hans/UI/Angular/Modifying-the-Menu.md
new file mode 100644
index 0000000000..ec3297ea78
--- /dev/null
+++ b/docs/zh-Hans/UI/Angular/Modifying-the-Menu.md
@@ -0,0 +1,197 @@
+# 修改菜单
+
+
+菜单在 @abp/ng.theme.basic包 `ApplicationLayoutComponent` 内部. 有几种修改菜单的方法,本文档介绍了这些方法. 如果你想完全替换菜单,请参考[组件替换文档]了解如何替换布局.
+
+
+
+## 如何添加Logo
+
+环境变量中的 `logoUrl` 是logo的url.
+
+你可以在 `src/assets` 文件夹下添加logo并设置 `logoUrl`:
+
+```js
+export const environment = {
+ // other configurations
+ application: {
+ name: 'MyProjectName',
+ logoUrl: 'assets/logo.png',
+ },
+ // other configurations
+};
+```
+
+## 如何添加导航元素
+
+### 通过 AppRoutingModule 中的 `routes` 属性
+
+你可以通过在 `app-routing.module` 中将路由作为子属性添加到路由配置的 `data` 属性来定义路由. `@abp/ng.core` 包组织路由并将其存储在 `ConfigState` 中.`ApplicationLayoutComponent` 从存储中获取路由显示在菜单上.
+
+你可以像以下一样添加 `routes` 属性:
+
+```js
+{
+ path: 'your-path',
+ data: {
+ routes: {
+ name: 'Your navigation',
+ order: 3,
+ iconClass: 'fas fa-question-circle',
+ requiredPolicy: 'permission key here',
+ children: [
+ {
+ path: 'child',
+ name: 'Your child navigation',
+ order: 1,
+ requiredPolicy: 'permission key here',
+ },
+ ],
+ } as ABP.Route, // can be imported from @abp/ng.core
+ }
+}
+```
+
+- `name` 是导航元素的标签,可以传递本地化密钥或本地化对象.
+- `order` 排序导航元素.
+- `iconClass` 是 `i` 标签的类,在导航标签的左侧.
+- `requiredPolicy` 是访问页面所需的权限key. 参阅 [权限管理文档](./Permission-Management.md)
+- `children` is an array and is used for declaring child navigation elements. The child navigation element will be placed as a child route which will be available at `'/your-path/child'` based on the given `path` property.
+- `children` 是一个数组,用于声明子菜单,它基于给定的 `path` 属性,路径是在`/your-path/child`.
+
+添加了上面描述的route属性后,导航菜单如下图所示:
+
+
+
+## 通过 ConfigState
+
+`ConfigStateService` 的 `dispatchAddRoute` 方法可以向菜单添加一个新的导航元素.
+
+```js
+// this.config is instance of ConfigStateService
+
+const newRoute: ABP.Route = {
+ name: 'My New Page',
+ iconClass: 'fa fa-dashboard',
+ path: 'page',
+ invisible: false,
+ order: 2,
+ requiredPolicy: 'MyProjectName.MyNewPage',
+} as Omit;
+
+this.config.dispatchAddRoute(newRoute);
+// returns a state stream which emits after dispatch action is complete
+```
+
+`newRoute` 放在根级别,没有任何父路由,url将为`/path`.
+
+如果你想 **添加子路由, 你可以这样做:**
+
+```js
+// this.config is instance of ConfigStateService
+// eIdentityRouteNames enum can be imported from @abp/ng.identity
+
+const newRoute: ABP.Route = {
+ parentName: eIdentityRouteNames.IdentityManagement,
+ name: 'My New Page',
+ iconClass: 'fa fa-dashboard',
+ path: 'page',
+ invisible: false,
+ order: 3,
+ requiredPolicy: 'MyProjectName.MyNewPage'
+} as Omit;
+
+this.config.dispatchAddRoute(newRoute);
+// returns a state stream which emits after dispatch action is complete
+```
+
+`newRoute` 做为 `eIdentityRouteNames.IdentityManagement` 的子路由添加, url 设置为 `'/identity/page'`.
+
+新路由看起来像这样:
+
+
+
+## 如何修改一个导航元素
+
+`DispatchPatchRouteByName` 方法通过名称查找路由,并使用二个参数传递的新配置替换存储中的配置.
+
+```js
+// this.config is instance of ConfigStateService
+// eIdentityRouteNames enum can be imported from @abp/ng.identity
+
+const newRouteConfig: Partial = {
+ iconClass: 'fas fa-home',
+ parentName: eIdentityRouteNames.Administration,
+ order: 0,
+ children: [
+ {
+ name: 'Dashboard',
+ path: 'dashboard',
+ },
+ ],
+};
+
+this.config.dispatchPatchRouteByName('::Menu:Home', newRouteConfig);
+// returns a state stream which emits after dispatch action is complete
+```
+
+* 根据给定的 `parentName` 将 _Home_ 导航移动到 _Administration_ 下拉框下.
+* 添加了 icon.
+* 指定了顺序.
+* 添加了名为 _Dashboard_ 的子路由.
+
+修改后,导航元素看起来像这样:
+
+
+
+## 如何在菜单的右侧添加元素
+
+右侧的元素存储在 @abp/ng.theme.basic 包的 `LayoutState` 中.
+
+`LayoutStateService` 的 `dispatchAddNavigationElement` 方法添加元素到右侧的菜单.
+
+你可以通过将模板添加到 `app.component` 调用 `dispatchAddNavigationElement` 方法来插入元素:
+
+```js
+import { Layout, LayoutStateService } from '@abp/ng.theme.basic'; // added this line
+
+@Component({
+ selector: 'app-root',
+ template: `
+
+
+
+ `,
+})
+export class AppComponent {
+ // Added ViewChild
+ @ViewChild('search', { static: false, read: TemplateRef }) searchElementRef: TemplateRef;
+
+ constructor(private layout: LayoutStateService) {} // injected LayoutStateService
+
+ // Added ngAfterViewInit
+ ngAfterViewInit() {
+ const newElement = {
+ name: 'Search',
+ element: this.searchElementRef,
+ order: 1,
+ } as Layout.NavigationElement;
+
+ this.layout.dispatchAddNavigationElement(newElement);
+ }
+}
+```
+
+上面我们在菜单添加了一个搜索输入,最终UI如下:s
+
+
+
+## 如何删除右侧菜单元素
+
+TODO
+
+## 下一步是什么?
+
+* [组件替换](./Component-Replacement.md)
diff --git a/docs/zh-Hans/UI/Angular/Permission-Management.md b/docs/zh-Hans/UI/Angular/Permission-Management.md
index 67ec1b787e..3a50da9591 100644
--- a/docs/zh-Hans/UI/Angular/Permission-Management.md
+++ b/docs/zh-Hans/UI/Angular/Permission-Management.md
@@ -76,4 +76,4 @@ const routes: Routes = [
## 下一步是什么?
-* [Config State](./Config-State.md)
\ No newline at end of file
+* [确认弹层](./Confirmation-Service.md)
\ No newline at end of file
diff --git a/docs/zh-Hans/UI/Angular/Projection-Strategy.md b/docs/zh-Hans/UI/Angular/Projection-Strategy.md
index e69de29bb2..efcf8b4190 100644
--- a/docs/zh-Hans/UI/Angular/Projection-Strategy.md
+++ b/docs/zh-Hans/UI/Angular/Projection-Strategy.md
@@ -0,0 +1,179 @@
+# ProjectionStrategy
+
+`ProjectionStrategy` 是@abp/ng.core包暴露出的抽象类. 有三种扩展它的投影策略: `ComponentProjectionStrategy`, `RootComponentProjectionStrategy` 和 `TemplateProjectionStrategy`. 它们实现相同的方法和属性,均可以帮助你定义内容投影的工作方式.
+
+## ComponentProjectionStrategy
+
+`ComponentProjectionStrategy` 是扩展 `ProjectionStrategy` 的类. 它使你可以将**组件投影到容器中**.
+
+### constructor
+
+```js
+constructor(
+ component: T,
+ private containerStrategy: ContainerStrategy,
+ private contextStrategy?: ContextStrategy,
+)
+```
+
+- `component` 是你要投影的组件的类.
+- `containerStrategy` 是在投影组件时将使用的 `ContainerStrategy`.
+- `contextStrategy` 是将在投影组件上使用的 `ContextStrategy`. (默认值: None_)
+
+请参阅[ContainerStrategy](./Container-Strategy.md)和[ContextStrategy](./Context-Strategy.md)文档以了解其用法.
+
+### injectContent
+
+```js
+injectContent(injector: Injector): ComponentRef
+```
+
+该方法准备容器,解析组件,设置其上下文并将其投影到容器中. 它返回一个 `ComponentRef` 实例,你应该保留该实例以便以后清除投影的组件.
+
+## RootComponentProjectionStrategy
+
+`RootComponentProjectionStrategy` 是扩展 `ProjectionStrategy` 的类. 它使你可以将**组件投影到文档中**,例如将其附加到 ``.
+
+### constructor
+
+```js
+constructor(
+ component: T,
+ private contextStrategy?: ContextStrategy,
+ private domStrategy?: DomStrategy,
+)
+```
+
+- `component` 是你要投影的组件的类.
+- `contextStrategy` 是将在投影组件上使用的 `ContextStrategy`. (默认值: None_)
+- `domStrategy` 是插入组件时将使用的 `DomStrategy`. (默认值: AppendToBody_)
+
+请参阅[ContextStrategy](./Context-Strategy.md)和[DomStrategy](./Dom-Strategy.md)文档以了解其用法.
+
+### injectContent
+
+```js
+injectContent(injector: Injector): ComponentRef
+```
+
+该方法解析组件,设置其上下文并将其投影到文档中. 它返回一个 `ComponentRef` 实例,你应该保留该实例以便以后清除投影的组件.
+
+## TemplateProjectionStrategy
+
+`TemplateProjectionStrategy` 是扩展 `ProjectionStrategy` 的类.它使你可以将**模板投影到容器中**.
+
+### constructor
+
+```js
+constructor(
+ template: T,
+ private containerStrategy: ContainerStrategy,
+ private contextStrategy?: ContextStrategy,
+)
+```
+
+- `template` 是你要投影的 `TemplateRef`.
+- `containerStrategy` 是在投影组件时将使用的 `ContainerStrategy`.
+- `contextStrategy` 是将在投影组件上使用的 `ContextStrategy`. (默认值: None_)
+
+请参阅[ContainerStrategy](./Container-Strategy.md)和[ContextStrategy](./Context-Strategy.md)文档以了解其用法.
+
+### injectContent
+
+```js
+injectContent(): EmbeddedViewRef
+```
+
+该方法准备容器,并将模板及其定义的上下文一起投影到容器. 它返回一个 `EmbeddedViewRef` 实例,你应该保留该实例以便以后清除投影的模板.
+
+## 预定义的投影策略
+
+可以通过 `PROJECTION_STRATEGY` 常量访问预定义的投影策略.
+
+### AppendComponentToBody
+
+```js
+PROJECTION_STRATEGY.AppendComponentToBody(
+ component: T,
+ contextStrategy?: ComponentContextStrategy,
+)
+```
+
+将给定上下文设置到组件并将放置在文档中 `` 标签的**末尾**.
+
+### AppendComponentToContainer
+
+```js
+PROJECTION_STRATEGY.AppendComponentToContainer(
+ component: T,
+ containerRef: ViewContainerRef,
+ contextStrategy?: ComponentContextStrategy,
+)
+```
+
+将给定上下文设置到组件并将放置在容器的**末尾**.
+
+### AppendTemplateToContainer
+
+```js
+PROJECTION_STRATEGY.AppendTemplateToContainer(
+ templateRef: T,
+ containerRef: ViewContainerRef,
+ contextStrategy?: ComponentContextStrategy,
+)
+```
+
+将给定上下文设置到模板并将其放置在容器的**末尾**.
+
+### PrependComponentToContainer
+
+```js
+PROJECTION_STRATEGY.PrependComponentToContainer(
+ component: T,
+ containerRef: ViewContainerRef,
+ contextStrategy?: ComponentContextStrategy,
+)
+```
+
+将给定上下文设置到组件并将其放置在容器的**开头**.
+
+### PrependTemplateToContainer
+
+```js
+PROJECTION_STRATEGY.PrependTemplateToContainer(
+ templateRef: T,
+ containerRef: ViewContainerRef,
+ contextStrategy?: ComponentContextStrategy,
+)
+```
+
+将给定上下文设置到模板并将其放置在容器的**开头**.
+
+
+### ProjectComponentToContainer
+
+```js
+PROJECTION_STRATEGY.ProjectComponentToContainer(
+ component: T,
+ containerRef: ViewContainerRef,
+ contextStrategy?: ComponentContextStrategy,
+)
+```
+
+清除容器,将给定的上下文设置到组件并放在**已清除**的容器中.
+
+### ProjectTemplateToContainer
+
+```js
+PROJECTION_STRATEGY.ProjectTemplateToContainer(
+ templateRef: T,
+ containerRef: ViewContainerRef,
+ contextStrategy?: ComponentContextStrategy,
+)
+```
+
+清除容器,将给定的上下文设置到模板并放在**已清除**的容器中.
+
+## 另请参阅
+
+- [DomInsertionService](./Dom-Insertion-Service.md)
diff --git a/docs/zh-Hans/UI/Angular/Service-Proxies.md b/docs/zh-Hans/UI/Angular/Service-Proxies.md
index 5c7e334891..29aafebdae 100644
--- a/docs/zh-Hans/UI/Angular/Service-Proxies.md
+++ b/docs/zh-Hans/UI/Angular/Service-Proxies.md
@@ -1,3 +1,68 @@
## 服务代理
-TODO...
\ No newline at end of file
+从Angular应用程序中调用服务器中的REST端点是很常见的, 在这种情况下我们通常创建**服务**(在服务器端具有针对每个服务方法的方法)和**模型对象**(与服务器端[DTO](../../Data-Transfer-Objects)匹配).
+
+除了手动创建这样的服务器交互服务之外,我们还可以使用[NSWAG](https://github.com/RicoSuter/NSwag)之类的工具来为我们生成服务代理. 但使用NSWAG过程中我们遇到以下问题:
+
+* 它生成一个**大的单个.ts文件**,该文件存在一些问题;
+ * 当你的应用程序增长时,它会变的**越来越大**.
+ * 它不适合ABP框架的[模块化](../../Module-Development-Basics)方法
+* 它创建了一些**难看的代码**. 我们希望有一个干净的代码(就像我们手动编写一样).
+* 它不能生成在服务器端声明的相同**方法签名**(因为swagger.json并不完全反映后端服务的方法签名). 我们已经创建了一个端点公开了服务器端方法信息,以便客户端生成更好的一致的客户端代理.
+
+ABP CLI 的`generate-proxies` 命令在 `src/app` 文件夹中创建按模块名称分隔的文件夹,自动生成typescript客户端代理.
+
+在angular应用程序的**根文件夹**中运行以下命令:
+
+```bash
+abp generate-proxy
+```
+
+它只为你自己的应用程序的服务创建代理. 不会为你正在使用的应用程序模块的服务创建代理(默认情况下). 有几个选项,参见[CLI文档](../../CLI).
+
+使用 `--module all` 选项生成的文件如下所示:
+
+
+
+### Services
+
+每个生成的服务都与后端控制器匹配. 服务方法通过[RestService](./Http-Requests#restservice)调用后端API.
+
+在每个服务中都定义了一个名为 `apiName` 的变量(自v2.4起可用). `apiName` 与模块的 `RemoteServiceName` 匹配. 在每次请求时该变量将作为参数传递给 `RestService`. 如果环境中未定义微服务API, `RestService` 使用默认值. 请参阅[从应用程序配置中获取特定的API端点](./Http-Requests#how-to-get-a-specific-api-endpoint-from-application-config)
+
+服务的 `providerIn` 属性定义为 `'root'`. 因此无需将服务作为提供程序添加到模块. 你可以通过将服务注入到构造函数中来使用它,如下所示:
+
+```js
+import { AbpApplicationConfigurationService } from '../app/shared/services';
+
+//...
+export class HomeComponent{
+ constructor(private appConfigService: AbpApplicationConfigurationService) {}
+
+ ngOnInit() {
+ this.appConfigService.get().subscribe()
+ }
+}
+```
+
+Angular编译器会从最终输出中删除那些没有被注入的服务. 参见[摇树优化的提供者文档](https://angular.cn/guide/dependency-injection-providers#tree-shakable-providers).
+
+### Models
+
+生成的模型与后端中的dto匹配. 每个模型在 `src/app/*/shared/models` 文件夹生成一个类.
+
+`@abp/ng.core` 包有一些[基类](https://github.com/abpframework/abp/blob/dev/npm/ng-packs/packages/core/src/lib/models/dtos.ts). 一些模型扩展了这些类.
+
+可以如下所示创建一个类的实例:
+
+```js
+import { IdentityRoleCreateDto } from '../identity/shared/models';
+//...
+const instance = new IdentityRoleCreateDto({name: 'Role 1', isDefault: false, isPublic: true})
+```
+
+可以选择将初始值传递给每个类构造函数.
+
+## 下一步是什么?
+
+* [HTTP请求](./Http-Requests)
\ No newline at end of file
diff --git a/docs/zh-Hans/UI/Angular/Toaster-Service.md b/docs/zh-Hans/UI/Angular/Toaster-Service.md
new file mode 100644
index 0000000000..045cf9f2cf
--- /dev/null
+++ b/docs/zh-Hans/UI/Angular/Toaster-Service.md
@@ -0,0 +1,155 @@
+# Toast Overlay
+
+你可以通常将@abp/ng.theme.shared包提供的 `ToasterService` 放置在你项目的根级别下以覆盖显示消息.
+
+## 入门
+
+你不必在模块或组件级别提供 `ToasterService`,它已经在**根**级别提供,你可以在你的组件,指令或服务直接注入并使用它.
+
+```js
+import { ToasterService } from '@abp/ng.theme.shared';
+
+@Component({
+ /* class metadata here */
+})
+class DemoComponent {
+ constructor(private toaster: ToasterService) {}
+}
+```
+
+## 用法
+
+你可以使用 `ToasterService` 的 `success`, `warn`, `error` 和 `info` 方法显示一个overlay.
+
+### 如何显示一个Toast Overlay
+
+```js
+this.toast.success('Message', 'Title');
+```
+
+- `ToasterService` 方法接收三个参数,分别是 `message`, `title`, 和 `options`.
+- `success`, `warn`, `error`, 和 `info` 方法返回一个已打开的 toast overlay Id. 可以使用此id删除toast.
+
+### 如何显示具有给定选项的Toast Overlay
+
+选项可以作为第三个参数传递给`success`, `warn`, `error`, 和 `info` 方法:
+
+```js
+import { Toaster, ToasterService } from '@abp/ng.theme.shared';
+//...
+
+constructor(private toaster: ToasterService) {}
+
+//...
+const options: Partial = {
+ life: 10000,
+ sticky: false,
+ closable: true,
+ tapToDismiss: true,
+ messageLocalizationParams: ['Demo', '1'],
+ titleLocalizationParams: []
+ };
+
+ this.toaster.error('AbpUi::EntityNotFoundErrorMessage', 'AbpUi::Error', options);
+```
+
+- `life` 选项是关闭的时间毫秒数. 默认值是 `5000`.
+- `sticky` 选项为 `true` 时忽略 `life` 选项,将toast overlay留在屏幕上. 默认值是 `false`.
+- `closable` 选项为 `true` 时在toast overlay上显示关闭图标. 默认值是 `true`.
+- `tapToDismiss` 选项为 `true` 允许通过单击关闭toast overlay. 默认值是 `false`.
+- `yesText` 是确定按钮的文本,可以传递本地化键或本地化对象. 默认值是 `AbpUi::Yes`.
+- `messageLocalizationParams` 是用于消息本地化的插值参数.
+- `titleLocalizationParams` 是标题本地化的插值参数.
+
+使用上面的选项,toast overlay看起来像这样:
+
+
+
+### 如何删除 Toast Overlay
+
+已打开的toast overlay可以通过手动调用 `remove` 方法传递指定的 toast `id`删除.
+
+```js
+const toastId = this.toast.success('Message', 'Title')
+
+this.toast.remove(toastId);
+```
+
+### 如何删除所有的Toasts
+
+可以手动调用 `clear` 方法删除所有的已打开的toasts.
+
+```js
+this.toast.clear();
+```
+
+## API
+
+### success
+
+```js
+success(
+ message: Config.LocalizationParam,
+ title: Config.LocalizationParam,
+ options?: Partial,
+): number
+```
+
+- `Config` 命令空间可以从 `@abp/ng.core` 导入.
+- `Toaster` 命令空间可以从 `@abp/ng.theme.shared` 导入.
+
+> 请参见[`Config.LocalizationParam`类型](https://github.com/abpframework/abp/blob/master/npm/ng-packs/packages/core/src/lib/models/config.ts#L46)和[`Toaster` namespace](https://github.com/abpframework/abp/blob/master/npm/ng-packs/packages/theme-shared/src/lib/models/toaster.ts)
+
+### warn
+
+```js
+warn(
+ message: Config.LocalizationParam,
+ title: Config.LocalizationParam,
+ options?: Partial,
+): number
+```
+
+### error
+
+```js
+error(
+ message: Config.LocalizationParam,
+ title: Config.LocalizationParam,
+ options?: Partial,
+): number
+```
+
+### info
+
+```js
+info(
+ message: Config.LocalizationParam,
+ title: Config.LocalizationParam,
+ options?: Partial,
+): number
+```
+
+### remove
+
+```js
+remove(id: number): void
+```
+
+按给定的id移除打开的toast.
+
+### clear
+
+```js
+clear(): void
+```
+
+删除所有打开的toasts.
+
+## 另请参阅
+
+- [Confirmation Popup](./Confirmation-Service.md)
+
+## 确认弹层?
+
+- [Config State](./Config-State.md)
diff --git a/docs/zh-Hans/UI/Angular/images/confirmation.png b/docs/zh-Hans/UI/Angular/images/confirmation.png
new file mode 100644
index 0000000000..efe4c98ea7
Binary files /dev/null and b/docs/zh-Hans/UI/Angular/images/confirmation.png differ
diff --git a/docs/zh-Hans/UI/Angular/images/custom-settings.png b/docs/zh-Hans/UI/Angular/images/custom-settings.png
index 32d7516849..05dd3f695a 100644
Binary files a/docs/zh-Hans/UI/Angular/images/custom-settings.png and b/docs/zh-Hans/UI/Angular/images/custom-settings.png differ
diff --git a/docs/zh-Hans/UI/Angular/images/generated-files-via-generate-proxy.png b/docs/zh-Hans/UI/Angular/images/generated-files-via-generate-proxy.png
new file mode 100644
index 0000000000..77a120a35d
Binary files /dev/null and b/docs/zh-Hans/UI/Angular/images/generated-files-via-generate-proxy.png differ
diff --git a/docs/zh-Hans/UI/Angular/images/navigation-menu-after-patching.png b/docs/zh-Hans/UI/Angular/images/navigation-menu-after-patching.png
new file mode 100644
index 0000000000..2f6bf08c88
Binary files /dev/null and b/docs/zh-Hans/UI/Angular/images/navigation-menu-after-patching.png differ
diff --git a/docs/zh-Hans/UI/Angular/images/navigation-menu-search-input.png b/docs/zh-Hans/UI/Angular/images/navigation-menu-search-input.png
new file mode 100644
index 0000000000..ebdc05e3e0
Binary files /dev/null and b/docs/zh-Hans/UI/Angular/images/navigation-menu-search-input.png differ
diff --git a/docs/zh-Hans/UI/Angular/images/navigation-menu-via-app-routing.png b/docs/zh-Hans/UI/Angular/images/navigation-menu-via-app-routing.png
new file mode 100644
index 0000000000..4d5f61301c
Binary files /dev/null and b/docs/zh-Hans/UI/Angular/images/navigation-menu-via-app-routing.png differ
diff --git a/docs/zh-Hans/UI/Angular/images/navigation-menu-via-config-state.png b/docs/zh-Hans/UI/Angular/images/navigation-menu-via-config-state.png
new file mode 100644
index 0000000000..19944f154d
Binary files /dev/null and b/docs/zh-Hans/UI/Angular/images/navigation-menu-via-config-state.png differ
diff --git a/docs/zh-Hans/UI/Angular/images/toast.png b/docs/zh-Hans/UI/Angular/images/toast.png
new file mode 100644
index 0000000000..24cdd0fe0c
Binary files /dev/null and b/docs/zh-Hans/UI/Angular/images/toast.png differ
diff --git a/docs/zh-Hans/UI/Common/Utils/Linked-List.md b/docs/zh-Hans/UI/Common/Utils/Linked-List.md
index 871db960ab..53c356628f 100644
--- a/docs/zh-Hans/UI/Common/Utils/Linked-List.md
+++ b/docs/zh-Hans/UI/Common/Utils/Linked-List.md
@@ -1229,7 +1229,7 @@ find(predicate: ListIteratorFunction): ListNode | undefined
从链表中找到与给定谓词匹配的第一个节点:
```js
-list.addTailMany(['a', 'b', 'b', 'c']);
+list.addManyTail(['a', 'b', 'b', 'c']);
// "a" <-> "b" <-> "b" <-> "c"
@@ -1251,7 +1251,7 @@ findIndex(predicate: ListIteratorFunction): number
从链表中找到与给定谓词匹配的第一个节点的位置:
```js
-list.addTailMany(['a', 'b', 'b', 'c']);
+list.addManyTail(['a', 'b', 'b', 'c']);
// "a" <-> "b" <-> "b" <-> "c"
@@ -1279,7 +1279,7 @@ get(position: number): ListNode | undefined
查找并返回链表中特定位置的节点:
```js
-list.addTailMany(['a', 'b', 'c']);
+list.addManyTail(['a', 'b', 'c']);
// "a" <-> "b" <-> "c"
@@ -1303,7 +1303,7 @@ indexOf(value: T, compareFn?: ListComparisonFn): number
在链表中找到匹配给定值的第一个节点位置:
```js
-list.addTailMany(['a', 'b', 'b', 'c']);
+list.addManyTail(['a', 'b', 'b', 'c']);
// "a" <-> "b" <-> "b" <-> "c"
@@ -1325,7 +1325,7 @@ i3 === -1
你可以自定义比较器
```js
-list.addTailMany([{ x: 1 }, { x: 0 }, { x: 2 }, { x: 0 }, { x: 3 }]);
+list.addManyTail([{ x: 1 }, { x: 0 }, { x: 2 }, { x: 0 }, { x: 3 }]);
// {"x":1} <-> {"x":0} <-> {"x":2} <-> {"x":0} <-> {"x":3}
@@ -1365,7 +1365,7 @@ forEach(iteratorFn: ListIteratorFn): void
从头到尾在链表中的所有节点上运行回调函数:
```js
-list.addTailMany(['a', 'b', 'c']);
+list.addManyTail(['a', 'b', 'c']);
// "a" <-> "b" <-> "c"
@@ -1381,7 +1381,7 @@ list.forEach((node, index) => console.log(node.value + index));
链表是可迭代的. 换句话说你可以使用诸如`for ... of`之类的方法.
```js
-list.addTailMany(['a', 'b', 'c']);
+list.addManyTail(['a', 'b', 'c']);
// "a" <-> "b" <-> "c"
@@ -1405,7 +1405,7 @@ toArray(): T[]
转换链表值为数组:
```js
-list.addTailMany(['a', 'b', 'c']);
+list.addManyTail(['a', 'b', 'c']);
// "a" <-> "b" <-> "c"
@@ -1427,7 +1427,7 @@ toNodeArray(): T[]
转换链表节点为数组:
```js
-list.addTailMany(['a', 'b', 'c']);
+list.addManyTail(['a', 'b', 'c']);
// "a" <-> "b" <-> "c"
@@ -1449,7 +1449,7 @@ toString(mapperFn: ListMapperFn = JSON.stringify): string
将链表转换为节点及其关系的字符串表示形式:
```js
-list.addTailMany(['a', 2, 'c', { k: 4, v: 'd' }]);
+list.addManyTail(['a', 2, 'c', { k: 4, v: 'd' }]);
// "a" <-> 2 <-> "c" <-> {"k":4,"v":"d"}
@@ -1507,7 +1507,7 @@ export class ListNode {
- `previous`引用列表中的上一个节点.
```js
-list.addTailMany([ 0, 1, 2 ]);
+list.addManyTail([ 0, 1, 2 ]);
console.log(
list.head.value, // 0
diff --git a/docs/zh-Hans/docs-nav.json b/docs/zh-Hans/docs-nav.json
index 384c406475..c70284637d 100644
--- a/docs/zh-Hans/docs-nav.json
+++ b/docs/zh-Hans/docs-nav.json
@@ -5,13 +5,7 @@
"items": [
{
"text": "从启动模板开始",
- "path": "Getting-Started-With-Startup-Templates.md",
- "items": [
- {
- "text": "ASP.NET Core MVC 模板",
- "path": "Getting-Started-AspNetCore-MVC-Template.md"
- }
- ]
+ "path": "Getting-Started.md"
},
{
"text": "从空项目开始",
@@ -218,8 +212,11 @@
},
{
"text": "领域驱动设计",
- "path": "Domain-Driven-Design.md",
"items": [
+ {
+ "text": "概述",
+ "path": "Domain-Driven-Design.md"
+ },
{
"text": "领域层",
"items": [
@@ -324,10 +321,22 @@
"text": "权限管理",
"path": "UI/Angular/Permission-Management.md"
},
+ {
+ "text": "确认弹层",
+ "path": "UI/Angular/Confirmation-Service.md"
+ },
+ {
+ "text": "Toast Overlay",
+ "path": "UI/Angular/Toaster-Service.md"
+ },
{
"text": "配置状态",
"path": "UI/Angular/Config-State.md"
},
+ {
+ "text": "修改菜单",
+ "path": "UI/Angular/Modifying-the-Menu.md"
+ },
{
"text": "替换组件",
"path": "UI/Angular/Component-Replacement.md"
@@ -372,8 +381,11 @@
},
{
"text": "数据访问",
- "path":"Data-Access.md",
"items": [
+ {
+ "text": "概述",
+ "path": "Data-Access.md"
+ },
{
"text": "连接字符串",
"path": "Connection-Strings.md"
@@ -457,8 +469,11 @@
},
{
"text": "启动模板",
- "path": "Startup-Templates/Index.md",
"items": [
+ {
+ "text": "概述",
+ "path": "Startup-Templates/Index.md"
+ },
{
"text": "应用程序",
"path": "Startup-Templates/Application.md"
diff --git a/docs/zh-Hans/docs-params.json b/docs/zh-Hans/docs-params.json
new file mode 100644
index 0000000000..23d079f9bb
--- /dev/null
+++ b/docs/zh-Hans/docs-params.json
@@ -0,0 +1,28 @@
+{
+ "parameters": [
+ {
+ "name": "UI",
+ "displayName": "UI",
+ "values": {
+ "MVC": "MVC / Razor Pages",
+ "NG": "Angular"
+ }
+ },
+ {
+ "name": "DB",
+ "displayName": "Database",
+ "values": {
+ "EF": "Entity Framework Core",
+ "Mongo": "MongoDB"
+ }
+ },
+ {
+ "name": "Tiered",
+ "displayName": "Tiered",
+ "values": {
+ "No": "Not Tiered",
+ "Yes": "Tiered"
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/framework/Volo.Abp.sln b/framework/Volo.Abp.sln
index 3db0998855..5159f0a86e 100644
--- a/framework/Volo.Abp.sln
+++ b/framework/Volo.Abp.sln
@@ -277,7 +277,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.Http.Client.Identi
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.ObjectExtending", "src\Volo.Abp.ObjectExtending\Volo.Abp.ObjectExtending.csproj", "{D1815C77-16D6-4F99-8814-69065CD89FB3}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.ObjectExtending.Tests", "test\Volo.Abp.ObjectExtending.Tests\Volo.Abp.ObjectExtending.Tests.csproj", "{17F8CA89-D9A2-4863-A5BD-B8E4D2901FD5}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.ObjectExtending.Tests", "test\Volo.Abp.ObjectExtending.Tests\Volo.Abp.ObjectExtending.Tests.csproj", "{17F8CA89-D9A2-4863-A5BD-B8E4D2901FD5}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.TextTemplating", "src\Volo.Abp.TextTemplating\Volo.Abp.TextTemplating.csproj", "{9E53F91F-EACD-4191-A487-E727741F1311}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.TextTemplating.Tests", "test\Volo.Abp.TextTemplating.Tests\Volo.Abp.TextTemplating.Tests.csproj", "{251C7FD3-D313-4BCE-8068-352EC7EEA275}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -829,6 +833,14 @@ Global
{17F8CA89-D9A2-4863-A5BD-B8E4D2901FD5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{17F8CA89-D9A2-4863-A5BD-B8E4D2901FD5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{17F8CA89-D9A2-4863-A5BD-B8E4D2901FD5}.Release|Any CPU.Build.0 = Release|Any CPU
+ {9E53F91F-EACD-4191-A487-E727741F1311}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9E53F91F-EACD-4191-A487-E727741F1311}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9E53F91F-EACD-4191-A487-E727741F1311}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9E53F91F-EACD-4191-A487-E727741F1311}.Release|Any CPU.Build.0 = Release|Any CPU
+ {251C7FD3-D313-4BCE-8068-352EC7EEA275}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {251C7FD3-D313-4BCE-8068-352EC7EEA275}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {251C7FD3-D313-4BCE-8068-352EC7EEA275}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {251C7FD3-D313-4BCE-8068-352EC7EEA275}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -970,6 +982,8 @@ Global
{E1963439-2BE5-4DB5-8438-2A9A792A1ADA} = {447C8A77-E5F0-4538-8687-7383196D04EA}
{D1815C77-16D6-4F99-8814-69065CD89FB3} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6}
{17F8CA89-D9A2-4863-A5BD-B8E4D2901FD5} = {447C8A77-E5F0-4538-8687-7383196D04EA}
+ {9E53F91F-EACD-4191-A487-E727741F1311} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6}
+ {251C7FD3-D313-4BCE-8068-352EC7EEA275} = {447C8A77-E5F0-4538-8687-7383196D04EA}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BB97ECF4-9A84-433F-A80B-2A3285BDD1D5}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpDynamicformTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpDynamicformTagHelperService.cs
index 6f8ccf285a..a1601378d9 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpDynamicformTagHelperService.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpDynamicformTagHelperService.cs
@@ -43,6 +43,8 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
await ProcessFieldsAsync(context, output);
+ RemoveFormGroupItemsNotInModel(context, output, list);
+
SetContent(context, output, list, childContent);
SetFormAttributes(context, output);
@@ -143,6 +145,14 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
}
}
+
+ protected virtual void RemoveFormGroupItemsNotInModel(TagHelperContext context, TagHelperOutput output, List items)
+ {
+ var models = GetModels(context, output);
+
+ items.RemoveAll(x => models.All(m => !m.Name.Equals(x.PropertyName, StringComparison.InvariantCultureIgnoreCase)));
+ }
+
protected virtual async Task ProcessSelectGroupAsync(TagHelperContext context, TagHelperOutput output, ModelExpression model)
{
var abpSelectTagHelper = GetSelectGroupTagHelper(context, output, model);
@@ -152,7 +162,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
protected virtual AbpTagHelper GetSelectGroupTagHelper(TagHelperContext context, TagHelperOutput output, ModelExpression model)
{
- return IsRadioGroup(model.ModelExplorer) ?
+ return IsRadioGroup(model.ModelExplorer) ?
GetAbpRadioInputTagHelper(model) :
GetSelectTagHelper(model);
}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpInputTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpInputTagHelperService.cs
index 75fe4f23e7..470b60004e 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpInputTagHelperService.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpInputTagHelperService.cs
@@ -58,7 +58,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
protected virtual async Task<(string, bool)> GetFormInputGroupAsHtmlAsync(TagHelperContext context, TagHelperOutput output)
{
var (inputTag, isCheckBox) = await GetInputTagHelperOutputAsync(context, output);
-
+
var inputHtml = inputTag.Render(_encoder);
var label = await GetLabelAsHtmlAsync(context, output, inputTag, isCheckBox);
var info = GetInfoAsHtml(context, output, inputTag, isCheckBox);
@@ -161,7 +161,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
protected virtual void AddDisabledAttribute(TagHelperOutput inputTagHelperOutput)
{
- if (inputTagHelperOutput.Attributes.ContainsName("disabled") == false &&
+ if (inputTagHelperOutput.Attributes.ContainsName("disabled") == false &&
(TagHelper.IsDisabled || TagHelper.AspFor.ModelExplorer.GetAttribute() != null))
{
inputTagHelperOutput.Attributes.Add("disabled", "");
@@ -170,7 +170,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
protected virtual void AddReadOnlyAttribute(TagHelperOutput inputTagHelperOutput)
{
- if (inputTagHelperOutput.Attributes.ContainsName("readonly") == false &&
+ if (inputTagHelperOutput.Attributes.ContainsName("readonly") == false &&
(TagHelper.IsReadonly != false || TagHelper.AspFor.ModelExplorer.GetAttribute() != null))
{
inputTagHelperOutput.Attributes.Add("readonly", "");
@@ -400,9 +400,10 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
list.Add(new FormGroupItem
{
HtmlContent = html,
- Order = order
+ Order = order,
+ PropertyName = propertyName
});
}
}
}
-}
\ No newline at end of file
+}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpRadioInputTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpRadioInputTagHelperService.cs
index 6f71842b61..010cc1d075 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpRadioInputTagHelperService.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpRadioInputTagHelperService.cs
@@ -167,9 +167,10 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
list.Add(new FormGroupItem
{
HtmlContent = html,
- Order = order
+ Order = order,
+ PropertyName = propertyName
});
}
}
}
-}
\ No newline at end of file
+}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpSelectTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpSelectTagHelperService.cs
index b18bc6ed75..3ed4f63f82 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpSelectTagHelperService.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpSelectTagHelperService.cs
@@ -125,7 +125,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
return await GetLabelAsHtmlUsingTagHelperAsync(context, output) + GetRequiredSymbol(context, output);
}
-
+
protected virtual string GetRequiredSymbol(TagHelperContext context, TagHelperOutput output)
{
if (!TagHelper.DisplayRequiredSymbol)
@@ -221,7 +221,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
}
protected virtual List GetSelectItemsFromAttribute(
- SelectItems selectItemsAttribute,
+ SelectItems selectItemsAttribute,
ModelExplorer explorer)
{
var selectItems = selectItemsAttribute.GetItems(explorer)?.ToList();
@@ -329,9 +329,10 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
list.Add(new FormGroupItem
{
HtmlContent = html,
- Order = order
+ Order = order,
+ PropertyName = propertyName
});
}
}
}
-}
\ No newline at end of file
+}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/FormGroupItem.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/FormGroupItem.cs
index 258ba544f8..e3d33a4359 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/FormGroupItem.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/FormGroupItem.cs
@@ -5,5 +5,7 @@
public string HtmlContent { get; set; }
public int Order { get; set; }
+
+ public string PropertyName { get; set; }
}
}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/pl.json b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/pl-PL.json
similarity index 92%
rename from framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/pl.json
rename to framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/pl-PL.json
index 8509b7d02b..438d770a7c 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/pl.json
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/pl-PL.json
@@ -1,5 +1,5 @@
{
- "culture": "pl",
+ "culture": "pl-PL",
"texts": {
"GivenTenantIsNotAvailable": "Podany tenant jest niedostępny: {0}",
"Tenant": "Tenant",
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/UpdateCommand.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/UpdateCommand.cs
index e6a2319c72..ca8bfa9bf8 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/UpdateCommand.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/UpdateCommand.cs
@@ -57,7 +57,11 @@ namespace Volo.Abp.Cli.Commands
.Options
.GetOrNull(Options.IncludePreviews.Short, Options.IncludePreviews.Long) != null;
- var solution = Directory.GetFiles(directory, "*.sln", SearchOption.AllDirectories).FirstOrDefault();
+ var solution = commandLineArgs.Options.GetOrNull(Options.SolutionName.Short, Options.SolutionName.Long);
+ if (solution.IsNullOrWhiteSpace())
+ {
+ solution = Directory.GetFiles(directory, "*.sln", SearchOption.AllDirectories).FirstOrDefault();
+ }
if (solution != null)
{
@@ -101,11 +105,14 @@ namespace Volo.Abp.Cli.Commands
sb.AppendLine("-p|--include-previews (if supported by the template)");
sb.AppendLine("--npm (Only updates NPM packages)");
sb.AppendLine("--nuget (Only updates Nuget packages)");
+ sb.AppendLine("-sp|--solution-path (Specify the solution path)");
+ sb.AppendLine("-sn|--solution-name (Specify the solution name)");
sb.AppendLine("");
sb.AppendLine("Some examples:");
sb.AppendLine("");
sb.AppendLine(" abp update");
sb.AppendLine(" abp update -p");
+ sb.AppendLine(" abp update -sp \"D:\\projects\\\" -sn Acme.BookStore");
sb.AppendLine("");
sb.AppendLine("See the documentation for more info: https://docs.abp.io/en/abp/latest/CLI");
@@ -125,6 +132,12 @@ namespace Volo.Abp.Cli.Commands
public const string Long = "solution-path";
}
+ public static class SolutionName
+ {
+ public const string Short = "sn";
+ public const string Long = "solution-name";
+ }
+
public static class IncludePreviews
{
public const string Short = "p";
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Http/CliHttpClient.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Http/CliHttpClient.cs
index ca1a23fcfc..bd3037d830 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Http/CliHttpClient.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Http/CliHttpClient.cs
@@ -1,9 +1,15 @@
using System;
+using System.Collections.Generic;
using System.IO;
using System.Net.Http;
using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
using IdentityModel.Client;
+using Polly;
+using Polly.Extensions.Http;
using Volo.Abp.Cli.Auth;
+using Microsoft.Extensions.Logging;
namespace Volo.Abp.Cli.Http
{
@@ -41,5 +47,55 @@ namespace Volo.Abp.Cli.Http
client.SetBearerToken(accessToken);
}
}
+
+ public async Task GetHttpResponseMessageWithRetryAsync
+ (
+ string url,
+ CancellationToken? cancellationToken = null,
+ ILogger logger = null,
+ IEnumerable sleepDurations = null
+ )
+ {
+ if (sleepDurations == null)
+ {
+ sleepDurations = new[]
+ {
+ TimeSpan.FromSeconds(2),
+ TimeSpan.FromSeconds(4),
+ TimeSpan.FromSeconds(7)
+ };
+ }
+
+ if (!cancellationToken.HasValue)
+ {
+ cancellationToken = CancellationToken.None;
+ }
+
+ return await HttpPolicyExtensions
+ .HandleTransientHttpError()
+ .OrResult(msg => !msg.IsSuccessStatusCode)
+ .WaitAndRetryAsync(sleepDurations,
+ (responseMessage, timeSpan, retryCount, context) =>
+ {
+ if (responseMessage.Exception != null)
+ {
+ string httpErrorCode = responseMessage.Result == null ?
+ httpErrorCode = string.Empty :
+ "HTTP-" + (int)responseMessage.Result.StatusCode + ", ";
+
+ logger?.LogWarning(
+ $"{retryCount}. HTTP request attempt failed to {url} with an error: {httpErrorCode}{responseMessage.Exception.Message}. " +
+ $"Waiting {timeSpan.TotalSeconds} secs for the next try...");
+ }
+ else if (responseMessage.Result != null)
+ {
+ logger?.LogWarning(
+ $"{retryCount}. HTTP request attempt failed to {url} with an error: {(int)responseMessage.Result.StatusCode}-{responseMessage.Result.ReasonPhrase}. " +
+ $"Waiting {timeSpan.TotalSeconds} secs for the next try...");
+ }
+ })
+ .ExecuteAsync(async () => await this.GetAsync(url, cancellationToken.Value));
+ }
+
}
}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Licensing/AbpIoApiKeyService.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Licensing/AbpIoApiKeyService.cs
index cddead548f..33a2e10fdf 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Licensing/AbpIoApiKeyService.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Licensing/AbpIoApiKeyService.cs
@@ -13,6 +13,7 @@ using Volo.Abp.Cli.Http;
using Volo.Abp.Cli.ProjectBuilding;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Json;
+using Volo.Abp.Threading;
namespace Volo.Abp.Cli.Licensing
{
@@ -20,14 +21,21 @@ namespace Volo.Abp.Cli.Licensing
{
protected IJsonSerializer JsonSerializer { get; }
protected IRemoteServiceExceptionHandler RemoteServiceExceptionHandler { get; }
+ protected ICancellationTokenProvider CancellationTokenProvider { get; }
+
private readonly ILogger _logger;
private DeveloperApiKeyResult _apiKeyResult = null;
- public AbpIoApiKeyService(IJsonSerializer jsonSerializer, IRemoteServiceExceptionHandler remoteServiceExceptionHandler, ILogger logger)
+ public AbpIoApiKeyService(
+ IJsonSerializer jsonSerializer,
+ ICancellationTokenProvider cancellationTokenProvider,
+ IRemoteServiceExceptionHandler remoteServiceExceptionHandler,
+ ILogger logger)
{
JsonSerializer = jsonSerializer;
RemoteServiceExceptionHandler = remoteServiceExceptionHandler;
_logger = logger;
+ CancellationTokenProvider = cancellationTokenProvider;
}
public async Task GetApiKeyOrNullAsync(bool invalidateCache = false)
@@ -51,31 +59,10 @@ namespace Volo.Abp.Cli.Licensing
using (var client = new CliHttpClient())
{
- var response = await HttpPolicyExtensions
- .HandleTransientHttpError()
- .OrResult(msg => !msg.IsSuccessStatusCode)
- .WaitAndRetryAsync(new[]
- {
- TimeSpan.FromSeconds(1),
- TimeSpan.FromSeconds(3),
- TimeSpan.FromSeconds(7)
- },
- (responseMessage, timeSpan, retryCount, context) =>
- {
- if (responseMessage.Exception != null)
- {
- _logger.LogWarning(
- $"{retryCount}. request attempt failed to {url} with an error: \"{responseMessage.Exception.Message}\". " +
- $"Waiting {timeSpan.TotalSeconds} secs for the next try...");
- }
- else if (responseMessage.Result != null)
- {
- _logger.LogWarning(
- $"{retryCount}. request attempt failed {url} with {(int)responseMessage.Result.StatusCode}-{responseMessage.Result.ReasonPhrase}. " +
- $"Waiting {timeSpan.TotalSeconds} secs for the next try...");
- }
- })
- .ExecuteAsync(async () => await client.GetAsync(url));
+ var response = await client.GetHttpResponseMessageWithRetryAsync(
+ url: url,
+ cancellationToken: CancellationTokenProvider.Token,
+ logger: _logger);
if (!response.IsSuccessStatusCode)
{
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/NuGet/NuGetService.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/NuGet/NuGetService.cs
index c0eb6fd209..0fd35582bf 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/NuGet/NuGetService.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/NuGet/NuGetService.cs
@@ -1,16 +1,10 @@
using Newtonsoft.Json;
using NuGet.Versioning;
-using System;
using System.Collections.Generic;
-using System.IO;
using System.Linq;
-using System.Net;
-using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
-using Polly;
-using Polly.Extensions.Http;
using Volo.Abp.Cli.Auth;
using Volo.Abp.Cli.Http;
using Volo.Abp.Cli.Licensing;
@@ -29,6 +23,8 @@ namespace Volo.Abp.Cli.NuGet
protected ICancellationTokenProvider CancellationTokenProvider { get; }
protected IRemoteServiceExceptionHandler RemoteServiceExceptionHandler { get; }
private readonly IApiKeyService _apiKeyService;
+ private List _proPackageList;
+ private DeveloperApiKeyResult _apiKeyResult;
public NuGetService(
IJsonSerializer jsonSerializer,
@@ -45,20 +41,20 @@ namespace Volo.Abp.Cli.NuGet
public async Task GetLatestVersionOrNullAsync(string packageId, bool includePreviews = false, bool includeNightly = false)
{
- List proPackageList = null;
-
if (AuthService.IsLoggedIn())
{
- proPackageList = await GetProPackageListAsync();
+ if (_proPackageList == null)
+ {
+ _proPackageList = await GetProPackageListAsync();
+ }
}
string url;
if (includeNightly)
{
- url =
- $"https://www.myget.org/F/abp-nightly/api/v3/flatcontainer/{packageId.ToLowerInvariant()}/index.json";
+ url = $"https://www.myget.org/F/abp-nightly/api/v3/flatcontainer/{packageId.ToLowerInvariant()}/index.json";
}
- else if (proPackageList?.Contains(packageId) ?? false)
+ else if (_proPackageList?.Contains(packageId) ?? false)
{
url = await GetNuGetUrlForCommercialPackage(packageId);
}
@@ -67,15 +63,13 @@ namespace Volo.Abp.Cli.NuGet
url = $"https://api.nuget.org/v3-flatcontainer/{packageId.ToLowerInvariant()}/index.json";
}
-
using (var client = new CliHttpClient(setBearerToken: false))
{
- var responseMessage = await GetHttpResponseMessageWithRetryAsync(client, url);
-
- if (!responseMessage.IsSuccessStatusCode)
- {
- throw new Exception($"ERROR: Remote server returns '{responseMessage.StatusCode}'");
- }
+ var responseMessage = await client.GetHttpResponseMessageWithRetryAsync(
+ url,
+ cancellationToken: CancellationTokenProvider.Token,
+ logger: Logger
+ );
await RemoteServiceExceptionHandler.EnsureSuccessfulHttpResponseAsync(responseMessage);
@@ -98,62 +92,41 @@ namespace Volo.Abp.Cli.NuGet
private async Task GetNuGetUrlForCommercialPackage(string packageId)
{
- var apiKeyResult = await _apiKeyService.GetApiKeyOrNullAsync();
- return CliUrls.GetNuGetPackageInfoUrl(apiKeyResult.ApiKey, packageId);
- }
+ if (_apiKeyResult == null)
+ {
+ _apiKeyResult = await _apiKeyService.GetApiKeyOrNullAsync();
+ }
- private async Task GetHttpResponseMessageWithRetryAsync(HttpClient client, string url)
- {
- return await HttpPolicyExtensions
- .HandleTransientHttpError()
- .OrResult(msg => !msg.IsSuccessStatusCode)
- .WaitAndRetryAsync(new[]
- {
- TimeSpan.FromSeconds(2),
- TimeSpan.FromSeconds(4),
- TimeSpan.FromSeconds(7)
- },
- (responseMessage, timeSpan, retryCount, context) =>
- {
- if (responseMessage.Exception != null)
- {
- Logger.LogWarning(
- $"{retryCount}. HTTP request attempt failed to {url} with an error: HTTP {(int)responseMessage.Result.StatusCode}-{responseMessage.Exception.Message}. " +
- $"Waiting {timeSpan.TotalSeconds} secs for the next try...");
- }
- else if (responseMessage.Result != null)
- {
- Logger.LogWarning(
- $"{retryCount}. HTTP request attempt failed to {url} with an error: {(int)responseMessage.Result.StatusCode}-{responseMessage.Result.ReasonPhrase}. " +
- $"Waiting {timeSpan.TotalSeconds} secs for the next try...");
- }
- })
- .ExecuteAsync(async () => await client.GetAsync(url, CancellationTokenProvider.Token));
+ return CliUrls.GetNuGetPackageInfoUrl(_apiKeyResult.ApiKey, packageId);
}
private async Task> GetProPackageListAsync()
{
using var client = new CliHttpClient();
- var responseMessage = await client.GetAsync(
- $"{CliUrls.WwwAbpIo}api/app/nugetPackage/proPackageNames",
- CancellationTokenProvider.Token
+ var url = $"{CliUrls.WwwAbpIo}api/app/nugetPackage/proPackageNames";
+
+ var responseMessage = await client.GetHttpResponseMessageWithRetryAsync(
+ url: url,
+ cancellationToken: CancellationTokenProvider.Token,
+ logger: Logger
);
- if (!responseMessage.IsSuccessStatusCode)
+ if (responseMessage.IsSuccessStatusCode)
{
- var exceptionMessage = "Remote server returns '" + (int)responseMessage.StatusCode + "-" + responseMessage.ReasonPhrase + "'. ";
- var remoteServiceErrorMessage = await RemoteServiceExceptionHandler.GetAbpRemoteServiceErrorAsync(responseMessage);
+ return JsonSerializer.Deserialize>(await responseMessage.Content.ReadAsStringAsync());
+ }
- if (remoteServiceErrorMessage != null)
- {
- exceptionMessage += remoteServiceErrorMessage;
- }
- Logger.LogInformation(exceptionMessage);
- return null;
+ var exceptionMessage = "Remote server returns '" + (int)responseMessage.StatusCode + "-" + responseMessage.ReasonPhrase + "'. ";
+ var remoteServiceErrorMessage = await RemoteServiceExceptionHandler.GetAbpRemoteServiceErrorAsync(responseMessage);
+
+ if (remoteServiceErrorMessage != null)
+ {
+ exceptionMessage += remoteServiceErrorMessage;
}
- return JsonSerializer.Deserialize>(await responseMessage.Content.ReadAsStringAsync());
+ Logger.LogError(exceptionMessage);
+ return null;
}
public class NuGetVersionResultDto
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/MyGetPackageListFinder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/MyGetPackageListFinder.cs
index 41907276f4..75e9156ce0 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/MyGetPackageListFinder.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/MyGetPackageListFinder.cs
@@ -20,7 +20,7 @@ namespace Volo.Abp.Cli.ProjectModification
Logger = NullLogger.Instance;
}
- public async Task GetPackages()
+ public async Task GetPackagesAsync()
{
if (_response != null)
{
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/NpmPackagesUpdater.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/NpmPackagesUpdater.cs
index a5a2e506cc..1a279fafc7 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/NpmPackagesUpdater.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/NpmPackagesUpdater.cs
@@ -13,25 +13,31 @@ using Volo.Abp.Cli.Http;
using Volo.Abp.Cli.Utils;
using Volo.Abp.DependencyInjection;
using Volo.Abp.IO;
+using Volo.Abp.Threading;
namespace Volo.Abp.Cli.ProjectModification
{
public class NpmPackagesUpdater : ITransientDependency
{
public ILogger Logger { get; set; }
+ protected ICancellationTokenProvider CancellationTokenProvider { get; }
private readonly PackageJsonFileFinder _packageJsonFileFinder;
private readonly NpmGlobalPackagesChecker _npmGlobalPackagesChecker;
private readonly MyGetPackageListFinder _myGetPackageListFinder;
-
private readonly Dictionary _fileVersionStorage = new Dictionary();
+ private MyGetApiResponse _myGetApiResponse;
- public NpmPackagesUpdater(PackageJsonFileFinder packageJsonFileFinder, NpmGlobalPackagesChecker npmGlobalPackagesChecker, MyGetPackageListFinder myGetPackageListFinder)
+ public NpmPackagesUpdater(
+ PackageJsonFileFinder packageJsonFileFinder,
+ NpmGlobalPackagesChecker npmGlobalPackagesChecker,
+ MyGetPackageListFinder myGetPackageListFinder,
+ ICancellationTokenProvider cancellationTokenProvider)
{
_packageJsonFileFinder = packageJsonFileFinder;
_npmGlobalPackagesChecker = npmGlobalPackagesChecker;
_myGetPackageListFinder = myGetPackageListFinder;
-
+ CancellationTokenProvider = cancellationTokenProvider;
Logger = NullLogger.Instance;
}
@@ -77,7 +83,7 @@ namespace Volo.Abp.Cli.ProjectModification
}
}
- private async Task DeleteNpmrcFileAsync(string directoryName)
+ private static async Task DeleteNpmrcFileAsync(string directoryName)
{
FileHelper.DeleteIfExists(Path.Combine(directoryName, ".npmrc"));
@@ -135,11 +141,13 @@ namespace Volo.Abp.Cli.ProjectModification
{
using (var client = new CliHttpClient(TimeSpan.FromMinutes(1)))
{
- var responseMessage = await client.GetAsync(
- $"{CliUrls.WwwAbpIo}api/myget/apikey/"
+ var response = await client.GetHttpResponseMessageWithRetryAsync(
+ url: $"{CliUrls.WwwAbpIo}api/myget/apikey/",
+ cancellationToken: CancellationTokenProvider.Token,
+ logger: Logger
);
- return Encoding.Default.GetString(await responseMessage.Content.ReadAsByteArrayAsync());
+ return Encoding.Default.GetString(await response.Content.ReadAsByteArrayAsync());
}
}
catch (Exception)
@@ -148,26 +156,26 @@ namespace Volo.Abp.Cli.ProjectModification
}
}
- private bool IsAngularProject(string fileDirectory)
+ private static bool IsAngularProject(string fileDirectory)
{
return File.Exists(Path.Combine(fileDirectory, "angular.json"));
}
- protected virtual async Task UpdatePackagesInFile(string file, bool includePreviews = false, bool switchToStable = false)
+ protected virtual async Task UpdatePackagesInFile(string filePath, bool includePreviews = false, bool switchToStable = false)
{
var packagesUpdated = false;
- var fileContent = File.ReadAllText(file);
+ var fileContent = File.ReadAllText(filePath);
var packageJson = JObject.Parse(fileContent);
var abpPackages = GetAbpPackagesFromPackageJson(packageJson);
if (!abpPackages.Any())
{
- return packagesUpdated;
+ return false;
}
foreach (var abpPackage in abpPackages)
{
- var updated = await TryUpdatePackage(file, abpPackage, includePreviews, switchToStable);
+ var updated = await TryUpdatingPackage(filePath, abpPackage, includePreviews, switchToStable);
if (updated)
{
@@ -175,15 +183,18 @@ namespace Volo.Abp.Cli.ProjectModification
}
}
- var modifiedFileContent = packageJson.ToString(Formatting.Indented);
+ var updatedContent = packageJson.ToString(Formatting.Indented);
- File.WriteAllText(file, modifiedFileContent);
+ File.WriteAllText(filePath, updatedContent);
return packagesUpdated;
}
- protected virtual async Task TryUpdatePackage(string file, JProperty package,
- bool includePreviews = false, bool switchToStable = false)
+ protected virtual async Task TryUpdatingPackage(
+ string filePath,
+ JProperty package,
+ bool includePreviews = false,
+ bool switchToStable = false)
{
var currentVersion = (string)package.Value;
@@ -198,23 +209,31 @@ namespace Volo.Abp.Cli.ProjectModification
package.Value.Replace(versionWithPrefix);
- Logger.LogInformation($"Updated {package.Name} to {version} in {file.Replace(Directory.GetCurrentDirectory(), "")}.");
+ Logger.LogInformation($"Updated {package.Name} to {version} in {filePath.Replace(Directory.GetCurrentDirectory(), "")}.");
return true;
}
- protected virtual async Task GetLatestVersion(JProperty package, string currentVersion,
- bool includePreviews = false, bool switchToStable = false)
+ protected virtual async Task GetLatestVersion(
+ JProperty package,
+ string currentVersion,
+ bool includePreviews = false,
+ bool switchToStable = false)
{
if (_fileVersionStorage.ContainsKey(package.Name))
{
return _fileVersionStorage[package.Name];
}
- string newVersion = currentVersion;
+ var newVersion = currentVersion;
if (includePreviews || (!switchToStable && currentVersion.Contains("-preview")))
{
- var mygetPackage = (await _myGetPackageListFinder.GetPackages()).Packages.FirstOrDefault(p => p.Id == package.Name);
+ if (_myGetApiResponse == null)
+ {
+ _myGetApiResponse = await _myGetPackageListFinder.GetPackagesAsync();
+ }
+
+ var mygetPackage = _myGetApiResponse.Packages.FirstOrDefault(p => p.Id == package.Name);
if (mygetPackage != null)
{
newVersion = mygetPackage.Versions.Last();
@@ -225,7 +244,6 @@ namespace Volo.Abp.Cli.ProjectModification
newVersion = CmdHelper.RunCmdAndGetOutput($"npm show {package.Name} version");
}
-
_fileVersionStorage[package.Name] = newVersion;
return newVersion;
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/VoloNugetPackagesVersionUpdater.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/VoloNugetPackagesVersionUpdater.cs
index 587492804b..fb2a386ef9 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/VoloNugetPackagesVersionUpdater.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/VoloNugetPackagesVersionUpdater.cs
@@ -42,8 +42,9 @@ namespace Volo.Abp.Cli.ProjectModification
protected virtual async Task UpdateInternalAsync(string projectPath, bool includePreviews = false, bool switchToStable = false)
{
var fileContent = File.ReadAllText(projectPath);
+ var updatedContent = await UpdateVoloPackagesAsync(fileContent, includePreviews, switchToStable);
- File.WriteAllText(projectPath, await UpdateVoloPackagesAsync(fileContent, includePreviews, switchToStable));
+ File.WriteAllText(projectPath, updatedContent);
}
private async Task UpdateVoloPackagesAsync(string content, bool includePreviews = false, bool switchToStable = false)
@@ -74,16 +75,13 @@ namespace Volo.Abp.Cli.ProjectModification
var versionAttribute = package.Attributes["Version"];
var currentVersion = versionAttribute.Value;
- var packageVersion = SemanticVersion.Parse(currentVersion);
-
- Logger.LogDebug("Checking package: \"{0}\" - Current version: {1}", packageId, packageVersion);
+ var currentSemanticVersion = SemanticVersion.Parse(currentVersion);
+ Logger.LogDebug("Checking package: \"{0}\" - Current version: {1}", packageId, currentSemanticVersion);
if (includePreviews || (currentVersion.Contains("-preview") && !switchToStable))
{
- var latestVersion = (await _myGetPackageListFinder.GetPackages()).Packages
- .FirstOrDefault(p => p.Id == packageId)
- ?.Versions.LastOrDefault();
+ var latestVersion = await GetLatestVersionFromMyGet(packageId);
if (currentVersion != latestVersion)
{
@@ -99,14 +97,14 @@ namespace Volo.Abp.Cli.ProjectModification
{
var latestVersion = await _nuGetService.GetLatestVersionOrNullAsync(packageId);
- if (latestVersion != null && (currentVersion.Contains("-preview") || packageVersion < latestVersion))
+ if (latestVersion != null && (currentVersion.Contains("-preview") || currentSemanticVersion < latestVersion))
{
- Logger.LogInformation("Updating package \"{0}\" from v{1} to v{2}.", packageId, packageVersion.ToString(), latestVersion.ToString());
+ Logger.LogInformation("Updating package \"{0}\" from v{1} to v{2}.", packageId, currentSemanticVersion.ToString(), latestVersion.ToString());
versionAttribute.Value = latestVersion.ToString();
}
else
{
- Logger.LogInformation("Package: \"{0}-v{1}\" is up to date.", packageId, packageVersion);
+ Logger.LogInformation("Package: \"{0}-v{1}\" is up to date.", packageId, currentSemanticVersion);
}
}
}
@@ -116,11 +114,18 @@ namespace Volo.Abp.Cli.ProjectModification
}
catch (Exception ex)
{
- Logger.LogError("Cannot update volo packages! An error occured while updating the package \"{0}\". Error: {1}", packageId, ex.Message);
+ Logger.LogError("Cannot update Volo.* packages! An error occured while updating the package \"{0}\". Error: {1}", packageId, ex.Message);
Logger.LogException(ex);
}
return await Task.FromResult(content);
}
+
+ private async Task GetLatestVersionFromMyGet(string packageId)
+ {
+ var myGetPack = await _myGetPackageListFinder.GetPackagesAsync();
+
+ return myGetPack.Packages.FirstOrDefault(p => p.Id == packageId)?.Versions.LastOrDefault();
+ }
}
}
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Localization/CultureHelper.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Localization/CultureHelper.cs
index 92320f737c..d4d9cfb1c0 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/Localization/CultureHelper.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/Localization/CultureHelper.cs
@@ -10,7 +10,12 @@ namespace Volo.Abp.Localization
{
Check.NotNull(culture, nameof(culture));
- return Use(new CultureInfo(culture), uiCulture == null ? null : new CultureInfo(uiCulture));
+ return Use(
+ new CultureInfo(culture),
+ uiCulture == null
+ ? null
+ : new CultureInfo(uiCulture)
+ );
}
public static IDisposable Use([NotNull] CultureInfo culture, CultureInfo uiCulture = null)
@@ -29,5 +34,12 @@ namespace Volo.Abp.Localization
CultureInfo.CurrentUICulture = currentUiCulture;
});
}
+
+ public static string GetBaseCultureName(string cultureName)
+ {
+ return cultureName.Contains("-")
+ ? cultureName.Left(cultureName.IndexOf("-", StringComparison.Ordinal))
+ : cultureName;
+ }
}
}
diff --git a/framework/src/Volo.Abp.Emailing/Volo.Abp.Emailing.csproj b/framework/src/Volo.Abp.Emailing/Volo.Abp.Emailing.csproj
index be953a1f26..a2f83399a0 100644
--- a/framework/src/Volo.Abp.Emailing/Volo.Abp.Emailing.csproj
+++ b/framework/src/Volo.Abp.Emailing/Volo.Abp.Emailing.csproj
@@ -14,24 +14,21 @@
-
-
-
-
-
-
+
+
+
diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/AbpEmailingModule.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/AbpEmailingModule.cs
index c2e29a7ff7..afcbaf6aef 100644
--- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/AbpEmailingModule.cs
+++ b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/AbpEmailingModule.cs
@@ -1,12 +1,9 @@
-using System;
-using System.Collections.Generic;
-using Microsoft.Extensions.DependencyInjection;
-using Volo.Abp.BackgroundJobs;
+using Volo.Abp.BackgroundJobs;
using Volo.Abp.Emailing.Localization;
-using Volo.Abp.Emailing.Templates;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
using Volo.Abp.Settings;
+using Volo.Abp.TextTemplating;
using Volo.Abp.VirtualFileSystem;
namespace Volo.Abp.Emailing
@@ -15,15 +12,11 @@ namespace Volo.Abp.Emailing
typeof(AbpSettingsModule),
typeof(AbpVirtualFileSystemModule),
typeof(AbpBackgroundJobsAbstractionsModule),
- typeof(AbpLocalizationModule)
+ typeof(AbpLocalizationModule),
+ typeof(AbpTextTemplatingModule)
)]
public class AbpEmailingModule : AbpModule
{
- public override void PreConfigureServices(ServiceConfigurationContext context)
- {
- AutoAddDefinitionProviders(context.Services);
- }
-
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure(options =>
@@ -43,41 +36,5 @@ namespace Volo.Abp.Emailing
options.AddJob();
});
}
-
- private static void AutoAddDefinitionProviders(IServiceCollection services)
- {
- var definitionProviders = new List();
-
- services.OnRegistred(context =>
- {
-
- if (typeof(IEmailTemplateDefinitionProvider).IsAssignableFrom(context.ImplementationType))
- {
- definitionProviders.Add(context.ImplementationType);
- }
- });
-
- services.Configure(options =>
- {
- options.DefinitionProviders.AddIfNotContains(definitionProviders);
- });
- }
-
- public override void OnApplicationInitialization(ApplicationInitializationContext context)
- {
- using (var scope = context.ServiceProvider.CreateScope())
- {
- var emailTemplateDefinitionManager =
- scope.ServiceProvider.GetRequiredService();
-
- foreach (var templateDefinition in emailTemplateDefinitionManager.GetAll())
- {
- foreach (var contributor in templateDefinition.Contributors)
- {
- contributor.Initialize(new EmailTemplateInitializationContext(templateDefinition, scope.ServiceProvider));
- }
- }
- }
- }
}
}
diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/AbpEmailTemplateOptions.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/AbpEmailTemplateOptions.cs
deleted file mode 100644
index cb5a9d370b..0000000000
--- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/AbpEmailTemplateOptions.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using Volo.Abp.Collections;
-
-namespace Volo.Abp.Emailing.Templates
-{
- public class AbpEmailTemplateOptions
- {
- public string DefaultLayout { get; set; }
-
- public ITypeList DefinitionProviders { get; }
-
- public AbpEmailTemplateOptions()
- {
- DefaultLayout = StandardEmailTemplates.DefaultLayout;
-
- DefinitionProviders = new TypeList();
- }
- }
-}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/DefaultEmailTemplateProvider.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/DefaultEmailTemplateProvider.cs
index c15012f0bf..385e0ef178 100644
--- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/DefaultEmailTemplateProvider.cs
+++ b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/DefaultEmailTemplateProvider.cs
@@ -1,16 +1,26 @@
-using Volo.Abp.Emailing.Templates.VirtualFiles;
+using Volo.Abp.TextTemplating;
namespace Volo.Abp.Emailing.Templates
{
- public class DefaultEmailTemplateProvider : EmailTemplateDefinitionProvider
+ public class DefaultEmailTemplateProvider : TemplateDefinitionProvider
{
- public override void Define(IEmailTemplateDefinitionContext context)
+ public override void Define(ITemplateDefinitionContext context)
{
- context.Add(new EmailTemplateDefinition(StandardEmailTemplates.DefaultLayout, defaultCultureName: "en", isLayout: true, layout: null)
- .AddTemplateVirtualFiles("/Volo/Abp/Emailing/Templates/DefaultEmailTemplates/Layout"));
+ context.Add(
+ new TemplateDefinition(
+ StandardEmailTemplates.Layout,
+ defaultCultureName: "en",
+ isLayout: true
+ ).WithVirtualFilePath("/Volo/Abp/Emailing/Templates/Layout")
+ );
- context.Add(new EmailTemplateDefinition(StandardEmailTemplates.SimpleMessage, defaultCultureName: "en")
- .AddTemplateVirtualFiles("/Volo/Abp/Emailing/Templates/DefaultEmailTemplates/Message"));
+ context.Add(
+ new TemplateDefinition(
+ StandardEmailTemplates.Message,
+ defaultCultureName: "en",
+ layout: StandardEmailTemplates.Layout
+ ).WithVirtualFilePath("/Volo/Abp/Emailing/Templates/Message")
+ );
}
}
}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/DefaultEmailTemplates/Message/en.tpl b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/DefaultEmailTemplates/Message/en.tpl
deleted file mode 100644
index 6454b0b93a..0000000000
--- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/DefaultEmailTemplates/Message/en.tpl
+++ /dev/null
@@ -1 +0,0 @@
-{{message}}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/EmailTemplate.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/EmailTemplate.cs
deleted file mode 100644
index ad6f8c4839..0000000000
--- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/EmailTemplate.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-using System.Text;
-
-namespace Volo.Abp.Emailing.Templates
-{
- public class EmailTemplate
- {
- public EmailTemplateDefinition Definition { get; }
-
- public string Content => ContentBuilder.ToString();
-
- protected StringBuilder ContentBuilder { get; set; }
-
- public EmailTemplate(string content, EmailTemplateDefinition definition)
- {
- ContentBuilder = new StringBuilder(content);
- Definition = definition;
- }
-
- public virtual void SetLayout(EmailTemplate layoutTemplate)
- {
- if (!layoutTemplate.Definition.IsLayout)
- {
- throw new AbpException($"Given template is not a layout template: {layoutTemplate.Definition.Name}");
- }
-
- var newStrBuilder = new StringBuilder(layoutTemplate.Content);
- newStrBuilder.Replace("{{#content}}", ContentBuilder.ToString());
-
- ContentBuilder = newStrBuilder;
- }
-
- public virtual void SetContent(string content)
- {
- ContentBuilder = new StringBuilder(content);
- }
-
- public virtual void Replace(string name, string value)
- {
- ContentBuilder.Replace("{{" + name + "}}", value);
- }
- }
-}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/EmailTemplateContributorList.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/EmailTemplateContributorList.cs
deleted file mode 100644
index 44a91212ea..0000000000
--- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/EmailTemplateContributorList.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-
-namespace Volo.Abp.Emailing.Templates
-{
- public class EmailTemplateContributorList : List
- {
- public string GetOrNull(string cultureName)
- {
- foreach (var contributor in this.AsQueryable().Reverse())
- {
- var templateString = contributor.GetOrNull(cultureName);
- if (templateString != null)
- {
- return templateString;
- }
- }
-
- return null;
- }
- }
-}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/EmailTemplateDefinition.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/EmailTemplateDefinition.cs
deleted file mode 100644
index 19f0eb2fa7..0000000000
--- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/EmailTemplateDefinition.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System;
-using JetBrains.Annotations;
-
-namespace Volo.Abp.Emailing.Templates
-{
- public class EmailTemplateDefinition
- {
- public const string DefaultLayoutPlaceHolder = "_";
-
- public string Name { get; }
-
- public bool IsLayout { get; }
-
- public string Layout { get; set; }
-
- public Type LocalizationResource { get; set; }
-
- public EmailTemplateContributorList Contributors { get; }
-
- public string DefaultCultureName { get; }
-
- public bool SingleTemplateFile { get; }
-
- public EmailTemplateDefinition([NotNull] string name, Type localizationResource = null, bool isLayout = false,
- string layout = DefaultLayoutPlaceHolder, string defaultCultureName = null, bool singleTemplateFile = false)
- {
- Name = Check.NotNullOrWhiteSpace(name, nameof(name));
- LocalizationResource = localizationResource;
- Contributors = new EmailTemplateContributorList();
- IsLayout = isLayout;
- Layout = layout;
- DefaultCultureName = defaultCultureName;
- SingleTemplateFile = singleTemplateFile;
- }
- }
-}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/EmailTemplateDefinitionContext.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/EmailTemplateDefinitionContext.cs
deleted file mode 100644
index 03a6c95d8b..0000000000
--- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/EmailTemplateDefinitionContext.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-using System.Collections.Generic;
-using System.Collections.Immutable;
-
-namespace Volo.Abp.Emailing.Templates
-{
- public class EmailTemplateDefinitionContext : IEmailTemplateDefinitionContext
- {
- protected Dictionary EmailTemplates { get; }
-
- public EmailTemplateDefinitionContext(Dictionary emailTemplates)
- {
- EmailTemplates = emailTemplates;
- }
-
- public virtual EmailTemplateDefinition GetOrNull(string name)
- {
- return EmailTemplates.GetOrDefault(name);
- }
-
- public virtual IReadOnlyList GetAll()
- {
- return EmailTemplates.Values.ToImmutableList();
- }
-
- public virtual void Add(params EmailTemplateDefinition[] definitions)
- {
- if (definitions.IsNullOrEmpty())
- {
- return;
- }
-
- foreach (var definition in definitions)
- {
- EmailTemplates[definition.Name] = definition;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/EmailTemplateDefinitionDictionary.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/EmailTemplateDefinitionDictionary.cs
deleted file mode 100644
index aa36232156..0000000000
--- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/EmailTemplateDefinitionDictionary.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System.Collections.Generic;
-
-namespace Volo.Abp.Emailing.Templates
-{
- public class EmailTemplateDefinitionDictionary : Dictionary
- {
- public EmailTemplateDefinitionDictionary Add(EmailTemplateDefinition emailTemplateDefinition)
- {
- if (ContainsKey(emailTemplateDefinition.Name))
- {
- throw new AbpException(
- "There is already an email template definition with given name: " +
- emailTemplateDefinition.Name
- );
- }
-
- this[emailTemplateDefinition.Name] = emailTemplateDefinition;
-
- return this;
- }
- }
-}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/EmailTemplateDefinitionManager.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/EmailTemplateDefinitionManager.cs
deleted file mode 100644
index 0491dc867e..0000000000
--- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/EmailTemplateDefinitionManager.cs
+++ /dev/null
@@ -1,74 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.Immutable;
-using System.Linq;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Options;
-using Volo.Abp.DependencyInjection;
-
-namespace Volo.Abp.Emailing.Templates
-{
- public class EmailTemplateDefinitionManager : IEmailTemplateDefinitionManager, ISingletonDependency
- {
- protected Lazy> EmailTemplateDefinitions { get; }
-
- protected AbpEmailTemplateOptions Options { get; }
-
- protected IServiceProvider ServiceProvider { get; }
-
- public EmailTemplateDefinitionManager(
- IOptions options,
- IServiceProvider serviceProvider)
- {
- ServiceProvider = serviceProvider;
- Options = options.Value;
-
- EmailTemplateDefinitions =
- new Lazy>(CreateEmailTemplateDefinitions, true);
- }
-
- public virtual EmailTemplateDefinition Get(string name)
- {
- Check.NotNull(name, nameof(name));
-
- var template = GetOrNull(name);
-
- if (template == null)
- {
- throw new AbpException("Undefined template: " + name);
- }
-
- return template;
- }
-
- public virtual IReadOnlyList GetAll()
- {
- return EmailTemplateDefinitions.Value.Values.ToImmutableList();
- }
-
- public virtual EmailTemplateDefinition GetOrNull(string name)
- {
- return EmailTemplateDefinitions.Value.GetOrDefault(name);
- }
-
- protected virtual IDictionary CreateEmailTemplateDefinitions()
- {
- var templates = new Dictionary();
-
- using (var scope = ServiceProvider.CreateScope())
- {
- var providers = Options
- .DefinitionProviders
- .Select(p => scope.ServiceProvider.GetRequiredService(p) as IEmailTemplateDefinitionProvider)
- .ToList();
-
- foreach (var provider in providers)
- {
- provider.Define(new EmailTemplateDefinitionContext(templates));
- }
- }
-
- return templates;
- }
- }
-}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/EmailTemplateDefinitionProvider.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/EmailTemplateDefinitionProvider.cs
deleted file mode 100644
index e53505fafc..0000000000
--- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/EmailTemplateDefinitionProvider.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using Volo.Abp.DependencyInjection;
-
-namespace Volo.Abp.Emailing.Templates
-{
- public abstract class EmailTemplateDefinitionProvider : IEmailTemplateDefinitionProvider, ITransientDependency
- {
- public abstract void Define(IEmailTemplateDefinitionContext context);
- }
-}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/EmailTemplateInitializationContext.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/EmailTemplateInitializationContext.cs
deleted file mode 100644
index 8cd4b95bbd..0000000000
--- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/EmailTemplateInitializationContext.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using System;
-
-namespace Volo.Abp.Emailing.Templates
-{
- public class EmailTemplateInitializationContext
- {
- public EmailTemplateDefinition EmailTemplateDefinition { get; }
-
- public IServiceProvider ServiceProvider { get; }
-
- public EmailTemplateInitializationContext(EmailTemplateDefinition emailTemplateDefinition,
- IServiceProvider serviceProvider)
- {
- EmailTemplateDefinition = emailTemplateDefinition;
- ServiceProvider = serviceProvider;
- }
- }
-}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/EmailTemplateProvider.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/EmailTemplateProvider.cs
deleted file mode 100644
index 29fcf08664..0000000000
--- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/EmailTemplateProvider.cs
+++ /dev/null
@@ -1,121 +0,0 @@
-using System;
-using System.Globalization;
-using System.Threading.Tasks;
-using Microsoft.Extensions.Localization;
-using Microsoft.Extensions.Options;
-using Volo.Abp.DependencyInjection;
-using Volo.Abp.Localization;
-
-namespace Volo.Abp.Emailing.Templates
-{
- public class EmailTemplateProvider : IEmailTemplateProvider, ITransientDependency
- {
- protected IEmailTemplateDefinitionManager EmailTemplateDefinitionManager;
- protected ITemplateLocalizer TemplateLocalizer { get; }
- protected AbpEmailTemplateOptions Options { get; }
- protected IStringLocalizerFactory StringLocalizerFactory;
-
- public EmailTemplateProvider(IEmailTemplateDefinitionManager emailTemplateDefinitionManager,
- ITemplateLocalizer templateLocalizer, IStringLocalizerFactory stringLocalizerFactory,
- IOptions options)
- {
- EmailTemplateDefinitionManager = emailTemplateDefinitionManager;
- TemplateLocalizer = templateLocalizer;
- StringLocalizerFactory = stringLocalizerFactory;
- Options = options.Value;
- }
-
- public async Task GetAsync(string name)
- {
- return await GetAsync(name, CultureInfo.CurrentUICulture.Name);
- }
-
- public async Task GetAsync(string name, string cultureName)
- {
- return await GetInternalAsync(name, cultureName);
- }
-
- protected virtual async Task GetInternalAsync(string name, string cultureName)
- {
- var emailTemplateDefinition = EmailTemplateDefinitionManager.GetOrNull(name);
- if (emailTemplateDefinition == null)
- {
- // TODO: Localized message
- throw new AbpException($"email template {name} not definition");
- }
-
- var emailTemplateString = emailTemplateDefinition.Contributors.GetOrNull(cultureName);
- if (emailTemplateString == null && emailTemplateDefinition.DefaultCultureName != null)
- {
- emailTemplateString =
- emailTemplateDefinition.Contributors.GetOrNull(emailTemplateDefinition.DefaultCultureName);
- if (emailTemplateString != null)
- {
- cultureName = emailTemplateDefinition.DefaultCultureName;
- }
- }
-
- if (emailTemplateString != null)
- {
- var emailTemplate = new EmailTemplate(emailTemplateString, emailTemplateDefinition);
-
- await SetLayoutAsync(emailTemplateDefinition, emailTemplate, cultureName);
-
- if (emailTemplateDefinition.SingleTemplateFile)
- {
- await LocalizeAsync(emailTemplateDefinition, emailTemplate, cultureName);
- }
-
- return emailTemplate;
- }
-
- // TODO: Localized message
- throw new AbpException($"{cultureName} template not exist!");
- }
-
- protected virtual async Task SetLayoutAsync(EmailTemplateDefinition emailTemplateDefinition,
- EmailTemplate emailTemplate, string cultureName)
- {
- var layout = emailTemplateDefinition.Layout;
- if (layout.IsNullOrWhiteSpace())
- {
- return;
- }
-
- if (layout == EmailTemplateDefinition.DefaultLayoutPlaceHolder)
- {
- layout = Options.DefaultLayout;
- }
-
- var layoutTemplate = await GetInternalAsync(layout, cultureName);
-
- emailTemplate.SetLayout(layoutTemplate);
- }
-
- protected virtual Task LocalizeAsync(EmailTemplateDefinition emailTemplateDefinition,
- EmailTemplate emailTemplate, string cultureName)
- {
- if (emailTemplateDefinition.LocalizationResource == null)
- {
- return Task.CompletedTask;
- }
-
- var localizer = StringLocalizerFactory.Create(emailTemplateDefinition.LocalizationResource);
- if (cultureName != null)
- {
- using (CultureHelper.Use(new CultureInfo(cultureName)))
- {
- emailTemplate.SetContent(TemplateLocalizer.Localize(localizer, emailTemplate.Content));
- }
- }
- else
- {
- emailTemplate.SetContent(
- TemplateLocalizer.Localize(localizer, emailTemplate.Content)
- );
- }
-
- return Task.CompletedTask;
- }
- }
-}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/IEmailTemplateContributor.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/IEmailTemplateContributor.cs
deleted file mode 100644
index d2c2775845..0000000000
--- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/IEmailTemplateContributor.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace Volo.Abp.Emailing.Templates
-{
- public interface IEmailTemplateContributor
- {
- void Initialize(EmailTemplateInitializationContext context);
-
- string GetOrNull(string cultureName);
- }
-}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/IEmailTemplateDefinitionContext.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/IEmailTemplateDefinitionContext.cs
deleted file mode 100644
index 1641562ccf..0000000000
--- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/IEmailTemplateDefinitionContext.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace Volo.Abp.Emailing.Templates
-{
- public interface IEmailTemplateDefinitionContext
- {
- EmailTemplateDefinition GetOrNull(string name);
-
- void Add(params EmailTemplateDefinition[] definitions);
- }
-}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/IEmailTemplateDefinitionManager.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/IEmailTemplateDefinitionManager.cs
deleted file mode 100644
index 0936a2fe93..0000000000
--- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/IEmailTemplateDefinitionManager.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System.Collections.Generic;
-using JetBrains.Annotations;
-
-namespace Volo.Abp.Emailing.Templates
-{
- public interface IEmailTemplateDefinitionManager
- {
- [NotNull]
- EmailTemplateDefinition Get([NotNull] string name);
-
- IReadOnlyList GetAll();
-
- EmailTemplateDefinition GetOrNull(string name);
- }
-}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/IEmailTemplateDefinitionProvider.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/IEmailTemplateDefinitionProvider.cs
deleted file mode 100644
index 691d3874d6..0000000000
--- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/IEmailTemplateDefinitionProvider.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace Volo.Abp.Emailing.Templates
-{
- public interface IEmailTemplateDefinitionProvider
- {
- void Define(IEmailTemplateDefinitionContext context);
- }
-}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/IEmailTemplateProvider.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/IEmailTemplateProvider.cs
deleted file mode 100644
index ab68dbe2ca..0000000000
--- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/IEmailTemplateProvider.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using System.Threading.Tasks;
-
-namespace Volo.Abp.Emailing.Templates
-{
- public interface IEmailTemplateProvider
- {
- Task GetAsync(string name);
-
- Task GetAsync(string name, string cultureName);
- }
-}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/ITemplateRender.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/ITemplateRender.cs
deleted file mode 100644
index 35ac14c8fd..0000000000
--- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/ITemplateRender.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using System.Threading.Tasks;
-
-namespace Volo.Abp.Emailing.Templates
-{
- public interface ITemplateRender
- {
- Task RenderAsync(string template, object model = null);
- }
-}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/DefaultEmailTemplates/Layout/en.tpl b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/Layout/en.tpl
similarity index 84%
rename from framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/DefaultEmailTemplates/Layout/en.tpl
rename to framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/Layout/en.tpl
index 107fbb5230..57453a027f 100644
--- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/DefaultEmailTemplates/Layout/en.tpl
+++ b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/Layout/en.tpl
@@ -4,6 +4,6 @@
- {{#content}}
+ {{content}}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/Message/en.tpl b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/Message/en.tpl
new file mode 100644
index 0000000000..349de66b36
--- /dev/null
+++ b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/Message/en.tpl
@@ -0,0 +1 @@
+{{model.message}}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/StandardEmailTemplates.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/StandardEmailTemplates.cs
index 7e8cbedc68..6a60219a5e 100644
--- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/StandardEmailTemplates.cs
+++ b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/StandardEmailTemplates.cs
@@ -2,7 +2,7 @@
{
public static class StandardEmailTemplates
{
- public const string DefaultLayout = "Abp.DefaultLayout";
- public const string SimpleMessage = "Abp.SimpleMessage";
+ public const string Layout = "Abp.StandardEmailTemplates.Layout";
+ public const string Message = "Abp.StandardEmailTemplates.Message";
}
}
diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/TemplateRender.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/TemplateRender.cs
deleted file mode 100644
index 8c4e24017c..0000000000
--- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/TemplateRender.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System.Threading.Tasks;
-using Scriban;
-using Volo.Abp.DependencyInjection;
-
-namespace Volo.Abp.Emailing.Templates
-{
- public class TemplateRender : ITemplateRender, ITransientDependency
- {
- public async Task RenderAsync(string template, object model = null)
- {
- var scribanTemplate = Template.Parse(template);
- return await scribanTemplate.RenderAsync(model);
- }
- }
-}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/VirtualFiles/EmailTemplateDefinitionExtensions.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/VirtualFiles/EmailTemplateDefinitionExtensions.cs
deleted file mode 100644
index 7bee611d28..0000000000
--- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/VirtualFiles/EmailTemplateDefinitionExtensions.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-namespace Volo.Abp.Emailing.Templates.VirtualFiles
-{
- public static class EmailTemplateDefinitionExtensions
- {
- public static EmailTemplateDefinition AddTemplateVirtualFile(
- this EmailTemplateDefinition emailTemplateDefinition, string path)
- {
- emailTemplateDefinition.Contributors.Add(new SingleVirtualFileEmailTemplateContributor(path));
- return emailTemplateDefinition;
- }
-
- public static EmailTemplateDefinition AddTemplateVirtualFiles(
- this EmailTemplateDefinition emailTemplateDefinition, string path)
- {
- emailTemplateDefinition.Contributors.Add(new MultipleVirtualFilesEmailTemplateContributor(path));
- return emailTemplateDefinition;
- }
- }
-}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/VirtualFiles/MultipleVirtualFilesEmailTemplateContributor.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/VirtualFiles/MultipleVirtualFilesEmailTemplateContributor.cs
deleted file mode 100644
index 2ae5f88cc5..0000000000
--- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/VirtualFiles/MultipleVirtualFilesEmailTemplateContributor.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-using System;
-using System.Collections.Generic;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.FileProviders;
-using Volo.Abp.VirtualFileSystem;
-
-namespace Volo.Abp.Emailing.Templates.VirtualFiles
-{
- public class MultipleVirtualFilesEmailTemplateContributor : IEmailTemplateContributor
- {
- private readonly string _virtualPath;
-
- private IVirtualFileProvider _virtualFileProvider;
-
- private Dictionary _templateDictionary;
-
- private readonly object _syncObj = new object();
-
- public MultipleVirtualFilesEmailTemplateContributor(string virtualPath)
- {
- _virtualPath = virtualPath;
- }
-
- public void Initialize(EmailTemplateInitializationContext context)
- {
- _virtualFileProvider = context.ServiceProvider.GetRequiredService();
- }
-
- public string GetOrNull(string cultureName)
- {
- return GetTemplateDictionary().GetOrDefault(cultureName);
- }
-
- private Dictionary GetTemplateDictionary()
- {
- var dictionaries = _templateDictionary;
- if (dictionaries != null)
- {
- return dictionaries;
- }
-
- lock (_syncObj)
- {
- dictionaries = _templateDictionary;
- if (dictionaries != null)
- {
- return dictionaries;
- }
-
- _templateDictionary = new Dictionary();
- foreach (var file in _virtualFileProvider.GetDirectoryContents(_virtualPath))
- {
- if (file.IsDirectory)
- {
- continue;
- }
-
- // TODO: How to normalize file names?
- _templateDictionary.Add(file.Name.RemovePostFix(".tpl"), file.ReadAsString());
- }
-
- dictionaries = _templateDictionary;
- }
-
- return dictionaries;
- }
- }
-}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/VirtualFiles/SingleVirtualFileEmailTemplateContributor.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/VirtualFiles/SingleVirtualFileEmailTemplateContributor.cs
deleted file mode 100644
index d72d18e99a..0000000000
--- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/VirtualFiles/SingleVirtualFileEmailTemplateContributor.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.FileProviders;
-using Volo.Abp.VirtualFileSystem;
-
-namespace Volo.Abp.Emailing.Templates.VirtualFiles
-{
- public class SingleVirtualFileEmailTemplateContributor : IEmailTemplateContributor
- {
- private readonly string _virtualPath;
-
- private IVirtualFileProvider _virtualFileProvider;
-
- public SingleVirtualFileEmailTemplateContributor(string virtualPath)
- {
- _virtualPath = virtualPath;
- }
-
- public void Initialize(EmailTemplateInitializationContext context)
- {
- _virtualFileProvider = context.ServiceProvider.GetRequiredService();
- }
-
- public string GetOrNull(string cultureName)
- {
- var file = _virtualFileProvider.GetFileInfo(_virtualPath);
- if (file == null || !file.Exists || file.IsDirectory)
- {
- return null;
- }
-
- return file.ReadAsString();
- }
- }
-}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/EntityHistory/EntityHistoryHelper.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/EntityHistory/EntityHistoryHelper.cs
index af728686fd..8db091eb30 100644
--- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/EntityHistory/EntityHistoryHelper.cs
+++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/EntityHistory/EntityHistoryHelper.cs
@@ -32,7 +32,7 @@ namespace Volo.Abp.EntityFrameworkCore.EntityHistory
IAuditingStore auditingStore,
IOptions options,
IClock clock,
- IJsonSerializer jsonSerializer,
+ IJsonSerializer jsonSerializer,
IAuditingHelper auditingHelper)
{
_clock = clock;
@@ -241,7 +241,8 @@ namespace Volo.Abp.EntityFrameworkCore.EntityHistory
}
}
- if (propertyEntry.IsModified)
+ var isModified = !(propertyEntry.OriginalValue?.Equals(propertyEntry.CurrentValue) ?? propertyEntry.CurrentValue == null);
+ if (isModified)
{
return true;
}
diff --git a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpDictionaryBasedStringLocalizer.cs b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpDictionaryBasedStringLocalizer.cs
index 79c164eb5f..53a2d7714e 100644
--- a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpDictionaryBasedStringLocalizer.cs
+++ b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpDictionaryBasedStringLocalizer.cs
@@ -104,7 +104,7 @@ namespace Volo.Abp.Localization
//Try to get from same language dictionary (without country code)
if (cultureName.Contains("-")) //Example: "tr-TR" (length=5)
{
- var strLang = Resource.Contributors.GetOrNull(GetBaseCultureName(cultureName), name);
+ var strLang = Resource.Contributors.GetOrNull(CultureHelper.GetBaseCultureName(cultureName), name);
if (strLang != null)
{
return strLang;
@@ -168,7 +168,7 @@ namespace Volo.Abp.Localization
//Overwrite all strings from the language based on country culture
if (cultureName.Contains("-"))
{
- Resource.Contributors.Fill(GetBaseCultureName(cultureName), allStrings);
+ Resource.Contributors.Fill(CultureHelper.GetBaseCultureName(cultureName), allStrings);
}
}
@@ -178,12 +178,7 @@ namespace Volo.Abp.Localization
return allStrings.Values.ToImmutableList();
}
- protected virtual string GetBaseCultureName(string cultureName)
- {
- return cultureName.Contains("-")
- ? cultureName.Left(cultureName.IndexOf("-", StringComparison.Ordinal))
- : cultureName;
- }
+
public class CultureWrapperStringLocalizer : IStringLocalizer, IStringLocalizerSupportsInheritance
{
diff --git a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/LocalizationResourceContributorList.cs b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/LocalizationResourceContributorList.cs
index daa6abe667..a81adf3562 100644
--- a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/LocalizationResourceContributorList.cs
+++ b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/LocalizationResourceContributorList.cs
@@ -8,7 +8,7 @@ namespace Volo.Abp.Localization
{
public LocalizedString GetOrNull(string cultureName, string name)
{
- foreach (var contributor in this.AsQueryable().Reverse()) //TODO: Reverse?
+ foreach (var contributor in this.AsQueryable().Reverse())
{
var localString = contributor.GetOrNull(cultureName, name);
if (localString != null)
diff --git a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/TemplateLocalizer.cs b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/TemplateLocalizer.cs
deleted file mode 100644
index 5c4220c45f..0000000000
--- a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/TemplateLocalizer.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using System.Text.RegularExpressions;
-using Microsoft.Extensions.Localization;
-using Volo.Abp.DependencyInjection;
-
-namespace Volo.Abp.Localization
-{
- public class TemplateLocalizer : ITemplateLocalizer, ITransientDependency
- {
- public string Localize(IStringLocalizer localizer, string text)
- {
- return new Regex("\\{\\{#L:.+?\\}\\}")
- .Replace(
- text,
- match => localizer[match.Value.Substring(5, match.Length - 7)]
- );
- }
- }
-}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.TextTemplating/FodyWeavers.xml b/framework/src/Volo.Abp.TextTemplating/FodyWeavers.xml
new file mode 100644
index 0000000000..be0de3a908
--- /dev/null
+++ b/framework/src/Volo.Abp.TextTemplating/FodyWeavers.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.TextTemplating/FodyWeavers.xsd b/framework/src/Volo.Abp.TextTemplating/FodyWeavers.xsd
new file mode 100644
index 0000000000..3f3946e282
--- /dev/null
+++ b/framework/src/Volo.Abp.TextTemplating/FodyWeavers.xsd
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.
+
+
+
+
+ A comma-separated list of error codes that can be safely ignored in assembly verification.
+
+
+
+
+ 'false' to turn off automatic generation of the XML Schema file.
+
+
+
+
+
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.TextTemplating/Volo.Abp.TextTemplating.csproj b/framework/src/Volo.Abp.TextTemplating/Volo.Abp.TextTemplating.csproj
new file mode 100644
index 0000000000..7bcc0400b5
--- /dev/null
+++ b/framework/src/Volo.Abp.TextTemplating/Volo.Abp.TextTemplating.csproj
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+ netstandard2.0
+ Volo.Abp.TextTemplating
+ Volo.Abp.TextTemplating
+ $(AssetTargetFallback);portable-net45+win8+wp8+wpa81;
+ false
+ false
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/framework/src/Volo.Abp.TextTemplating/Volo/Abp/TextTemplating/AbpTextTemplatingModule.cs b/framework/src/Volo.Abp.TextTemplating/Volo/Abp/TextTemplating/AbpTextTemplatingModule.cs
new file mode 100644
index 0000000000..8d76391829
--- /dev/null
+++ b/framework/src/Volo.Abp.TextTemplating/Volo/Abp/TextTemplating/AbpTextTemplatingModule.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using Microsoft.Extensions.DependencyInjection;
+using Volo.Abp.Localization;
+using Volo.Abp.Modularity;
+using Volo.Abp.VirtualFileSystem;
+
+namespace Volo.Abp.TextTemplating
+{
+ [DependsOn(
+ typeof(AbpVirtualFileSystemModule),
+ typeof(AbpLocalizationAbstractionsModule)
+ )]
+ public class AbpTextTemplatingModule : AbpModule
+ {
+ public override void PreConfigureServices(ServiceConfigurationContext context)
+ {
+ AutoAddProvidersAndContributors(context.Services);
+ }
+
+ private static void AutoAddProvidersAndContributors(IServiceCollection services)
+ {
+ var definitionProviders = new List();
+ var contentContributors = new List();
+
+ services.OnRegistred(context =>
+ {
+ if (typeof(ITemplateDefinitionProvider).IsAssignableFrom(context.ImplementationType))
+ {
+ definitionProviders.Add(context.ImplementationType);
+ }
+
+ if (typeof(ITemplateContentContributor).IsAssignableFrom(context.ImplementationType))
+ {
+ contentContributors.Add(context.ImplementationType);
+ }
+ });
+
+ services.Configure(options =>
+ {
+ options.DefinitionProviders.AddIfNotContains(definitionProviders);
+ options.ContentContributors.AddIfNotContains(contentContributors);
+ });
+ }
+ }
+}
diff --git a/framework/src/Volo.Abp.TextTemplating/Volo/Abp/TextTemplating/AbpTextTemplatingOptions.cs b/framework/src/Volo.Abp.TextTemplating/Volo/Abp/TextTemplating/AbpTextTemplatingOptions.cs
new file mode 100644
index 0000000000..b217094974
--- /dev/null
+++ b/framework/src/Volo.Abp.TextTemplating/Volo/Abp/TextTemplating/AbpTextTemplatingOptions.cs
@@ -0,0 +1,16 @@
+using Volo.Abp.Collections;
+
+namespace Volo.Abp.TextTemplating
+{
+ public class AbpTextTemplatingOptions
+ {
+ public ITypeList DefinitionProviders { get; }
+ public ITypeList ContentContributors { get; }
+
+ public AbpTextTemplatingOptions()
+ {
+ DefinitionProviders = new TypeList();
+ ContentContributors = new TypeList();
+ }
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.TextTemplating/Volo/Abp/TextTemplating/ITemplateContentContributor.cs b/framework/src/Volo.Abp.TextTemplating/Volo/Abp/TextTemplating/ITemplateContentContributor.cs
new file mode 100644
index 0000000000..746b29a2f0
--- /dev/null
+++ b/framework/src/Volo.Abp.TextTemplating/Volo/Abp/TextTemplating/ITemplateContentContributor.cs
@@ -0,0 +1,9 @@
+using System.Threading.Tasks;
+
+namespace Volo.Abp.TextTemplating
+{
+ public interface ITemplateContentContributor
+ {
+ Task GetOrNullAsync(TemplateContentContributorContext context);
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.TextTemplating/Volo/Abp/TextTemplating/ITemplateContentProvider.cs b/framework/src/Volo.Abp.TextTemplating/Volo/Abp/TextTemplating/ITemplateContentProvider.cs
new file mode 100644
index 0000000000..19248dc161
--- /dev/null
+++ b/framework/src/Volo.Abp.TextTemplating/Volo/Abp/TextTemplating/ITemplateContentProvider.cs
@@ -0,0 +1,22 @@
+using System.Threading.Tasks;
+using JetBrains.Annotations;
+
+namespace Volo.Abp.TextTemplating
+{
+ public interface ITemplateContentProvider
+ {
+ Task GetContentOrNullAsync(
+ [NotNull] string templateName,
+ [CanBeNull] string cultureName = null,
+ bool tryDefaults = true,
+ bool useCurrentCultureIfCultureNameIsNull = true
+ );
+
+ Task GetContentOrNullAsync(
+ [NotNull] TemplateDefinition templateDefinition,
+ [CanBeNull] string cultureName = null,
+ bool tryDefaults = true,
+ bool useCurrentCultureIfCultureNameIsNull = true
+ );
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.TextTemplating/Volo/Abp/TextTemplating/ITemplateDefinitionContext.cs b/framework/src/Volo.Abp.TextTemplating/Volo/Abp/TextTemplating/ITemplateDefinitionContext.cs
new file mode 100644
index 0000000000..515cee74ca
--- /dev/null
+++ b/framework/src/Volo.Abp.TextTemplating/Volo/Abp/TextTemplating/ITemplateDefinitionContext.cs
@@ -0,0 +1,13 @@
+using System.Collections.Generic;
+
+namespace Volo.Abp.TextTemplating
+{
+ public interface ITemplateDefinitionContext
+ {
+ IReadOnlyList GetAll(string name);
+
+ TemplateDefinition GetOrNull(string name);
+
+ void Add(params TemplateDefinition[] definitions);
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.TextTemplating/Volo/Abp/TextTemplating/ITemplateDefinitionManager.cs b/framework/src/Volo.Abp.TextTemplating/Volo/Abp/TextTemplating/ITemplateDefinitionManager.cs
new file mode 100644
index 0000000000..cbd2d15463
--- /dev/null
+++ b/framework/src/Volo.Abp.TextTemplating/Volo/Abp/TextTemplating/ITemplateDefinitionManager.cs
@@ -0,0 +1,17 @@
+using System.Collections.Generic;
+using JetBrains.Annotations;
+
+namespace Volo.Abp.TextTemplating
+{
+ public interface ITemplateDefinitionManager
+ {
+ [NotNull]
+ TemplateDefinition Get([NotNull] string name);
+
+ [NotNull]
+ IReadOnlyList GetAll();
+
+ [CanBeNull]
+ TemplateDefinition GetOrNull(string name);
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.TextTemplating/Volo/Abp/TextTemplating/ITemplateDefinitionProvider.cs b/framework/src/Volo.Abp.TextTemplating/Volo/Abp/TextTemplating/ITemplateDefinitionProvider.cs
new file mode 100644
index 0000000000..aeb6a3c2da
--- /dev/null
+++ b/framework/src/Volo.Abp.TextTemplating/Volo/Abp/TextTemplating/ITemplateDefinitionProvider.cs
@@ -0,0 +1,11 @@
+namespace Volo.Abp.TextTemplating
+{
+ public interface ITemplateDefinitionProvider
+ {
+ void PreDefine(ITemplateDefinitionContext context);
+
+ void Define(ITemplateDefinitionContext context);
+
+ void PostDefine(ITemplateDefinitionContext context);
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.TextTemplating/Volo/Abp/TextTemplating/ITemplateRenderer.cs b/framework/src/Volo.Abp.TextTemplating/Volo/Abp/TextTemplating/ITemplateRenderer.cs
new file mode 100644
index 0000000000..b153a5130b
--- /dev/null
+++ b/framework/src/Volo.Abp.TextTemplating/Volo/Abp/TextTemplating/ITemplateRenderer.cs
@@ -0,0 +1,25 @@
+using System.Collections.Generic;
+using System.Globalization;
+using System.Threading.Tasks;
+using JetBrains.Annotations;
+
+namespace Volo.Abp.TextTemplating
+{
+ public interface ITemplateRenderer
+ {
+ ///
+ /// Renders a text template.
+ ///
+ /// The template name
+ /// An optional model object that is used in the template
+ /// Culture name. Uses the if not specified
+ /// A dictionary which can be used to import global objects to the template
+ ///
+ Task RenderAsync(
+ [NotNull] string templateName,
+ [CanBeNull] object model = null,
+ [CanBeNull] string cultureName = null,
+ [CanBeNull] Dictionary globalContext = null
+ );
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.TextTemplating/Volo/Abp/TextTemplating/TemplateContentContributorContext.cs b/framework/src/Volo.Abp.TextTemplating/Volo/Abp/TextTemplating/TemplateContentContributorContext.cs
new file mode 100644
index 0000000000..773bf1a0a4
--- /dev/null
+++ b/framework/src/Volo.Abp.TextTemplating/Volo/Abp/TextTemplating/TemplateContentContributorContext.cs
@@ -0,0 +1,27 @@
+using System;
+using JetBrains.Annotations;
+
+namespace Volo.Abp.TextTemplating
+{
+ public class TemplateContentContributorContext
+ {
+ [NotNull]
+ public TemplateDefinition TemplateDefinition { get; }
+
+ [NotNull]
+ public IServiceProvider ServiceProvider { get; }
+
+ [CanBeNull]
+ public string Culture { get; }
+
+ public TemplateContentContributorContext(
+ [NotNull] TemplateDefinition templateDefinition,
+ [NotNull] IServiceProvider serviceProvider,
+ [CanBeNull] string culture)
+ {
+ TemplateDefinition = Check.NotNull(templateDefinition, nameof(templateDefinition));
+ ServiceProvider = Check.NotNull(serviceProvider, nameof(serviceProvider));
+ Culture = culture;
+ }
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.TextTemplating/Volo/Abp/TextTemplating/TemplateContentProvider.cs b/framework/src/Volo.Abp.TextTemplating/Volo/Abp/TextTemplating/TemplateContentProvider.cs
new file mode 100644
index 0000000000..55a3979e21
--- /dev/null
+++ b/framework/src/Volo.Abp.TextTemplating/Volo/Abp/TextTemplating/TemplateContentProvider.cs
@@ -0,0 +1,170 @@
+using System;
+using System.Globalization;
+using System.Linq;
+using System.Threading.Tasks;
+using JetBrains.Annotations;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Options;
+using Volo.Abp.DependencyInjection;
+using Volo.Abp.Localization;
+
+namespace Volo.Abp.TextTemplating
+{
+ public class TemplateContentProvider : ITemplateContentProvider, ITransientDependency
+ {
+ public IHybridServiceScopeFactory ServiceScopeFactory { get; }
+ public AbpTextTemplatingOptions Options { get; }
+ private readonly ITemplateDefinitionManager _templateDefinitionManager;
+
+ public TemplateContentProvider(
+ ITemplateDefinitionManager templateDefinitionManager,
+ IHybridServiceScopeFactory serviceScopeFactory,
+ IOptions