` 标签:
+
+```html
+
+
+
+
+
+ | {%{{{ "::Actions" | abpLocalization }}}%} |
+ {%{{{ "::Name" | abpLocalization }}}%} |
+ {%{{{ "::Type" | abpLocalization }}}%} |
+ {%{{{ "::PublishDate" | abpLocalization }}}%} |
+ {%{{{ "::Price" | 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
+
+
+
+
+```
+
+最终操作下拉框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..5d6f3e99a2 100644
--- a/framework/Volo.Abp.sln
+++ b/framework/Volo.Abp.sln
@@ -277,7 +277,13 @@ 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("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.TextTemplating", "src\Volo.Abp.TextTemplating\Volo.Abp.TextTemplating.csproj", "{9E53F91F-EACD-4191-A487-E727741F1311}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.TextTemplating.Tests", "test\Volo.Abp.TextTemplating.Tests\Volo.Abp.TextTemplating.Tests.csproj", "{251C7FD3-D313-4BCE-8068-352EC7EEA275}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Validation.Abstractions", "src\Volo.Abp.Validation.Abstractions\Volo.Abp.Validation.Abstractions.csproj", "{FA5D1D6A-2A05-4A3D-99C1-2B6C1D1F99A3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -829,6 +835,18 @@ 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
+ {FA5D1D6A-2A05-4A3D-99C1-2B6C1D1F99A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {FA5D1D6A-2A05-4A3D-99C1-2B6C1D1F99A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {FA5D1D6A-2A05-4A3D-99C1-2B6C1D1F99A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {FA5D1D6A-2A05-4A3D-99C1-2B6C1D1F99A3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -970,6 +988,9 @@ 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}
+ {FA5D1D6A-2A05-4A3D-99C1-2B6C1D1F99A3} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BB97ECF4-9A84-433F-A80B-2A3285BDD1D5}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationConfigurationDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationConfigurationDto.cs
index cc62a1e1b9..da99a3e948 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationConfigurationDto.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationConfigurationDto.cs
@@ -1,4 +1,5 @@
using System;
+using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending;
using Volo.Abp.AspNetCore.Mvc.MultiTenancy;
namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations
@@ -19,5 +20,7 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations
public MultiTenancyInfoDto MultiTenancy { get; set; }
public CurrentTenantDto CurrentTenant { get; set; }
+
+ public ObjectExtensionsDto ObjectExtensions { get; set; }
}
}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationLocalizationConfigurationDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationLocalizationConfigurationDto.cs
index a5e6574e93..8064ff99d2 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationLocalizationConfigurationDto.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationLocalizationConfigurationDto.cs
@@ -14,6 +14,8 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations
public CurrentCultureDto CurrentCulture { get; set; }
+ public string DefaultResourceName { get; set; }
+
public ApplicationLocalizationConfigurationDto()
{
Values = new Dictionary>();
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/CachedObjectExtensionsDtoService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/CachedObjectExtensionsDtoService.cs
new file mode 100644
index 0000000000..f87fef31aa
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/CachedObjectExtensionsDtoService.cs
@@ -0,0 +1,178 @@
+using System.Collections.Generic;
+using System.Linq;
+using Volo.Abp.DependencyInjection;
+using Volo.Abp.Localization;
+using Volo.Abp.ObjectExtending;
+using Volo.Abp.ObjectExtending.Modularity;
+using Volo.Abp.Reflection;
+
+namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending
+{
+ public class CachedObjectExtensionsDtoService : ICachedObjectExtensionsDtoService, ISingletonDependency
+ {
+ private volatile ObjectExtensionsDto _cachedValue;
+ private readonly object _syncLock = new object();
+
+ public virtual ObjectExtensionsDto Get()
+ {
+ if (_cachedValue == null)
+ {
+ lock (_syncLock)
+ {
+ if (_cachedValue == null)
+ {
+ _cachedValue = GenerateCacheValue();
+ }
+ }
+ }
+
+ return _cachedValue;
+ }
+
+ protected virtual ObjectExtensionsDto GenerateCacheValue()
+ {
+ var objectExtensionsDto = new ObjectExtensionsDto
+ {
+ Modules = new Dictionary()
+ };
+
+ foreach (var moduleConfig in ObjectExtensionManager.Instance.Modules())
+ {
+ objectExtensionsDto.Modules[moduleConfig.Key] = CreateModuleExtensionDto(moduleConfig.Value);
+ }
+
+ return objectExtensionsDto;
+ }
+
+ protected virtual ModuleExtensionDto CreateModuleExtensionDto(
+ ModuleExtensionConfiguration moduleConfig)
+ {
+ var moduleExtensionDto = new ModuleExtensionDto
+ {
+ Entities = new Dictionary()
+ };
+
+ foreach (var objectConfig in moduleConfig.Entities)
+ {
+ moduleExtensionDto.Entities[objectConfig.Key] = GetEntityExtensionDto(objectConfig.Value);
+ }
+
+ foreach (var customConfig in moduleConfig.Configuration.Where(c => !c.Key.StartsWith("_")))
+ {
+ moduleExtensionDto.Configuration[customConfig.Key] = customConfig.Value;
+ }
+
+ return moduleExtensionDto;
+ }
+
+ protected virtual EntityExtensionDto GetEntityExtensionDto(
+ EntityExtensionConfiguration entityConfig)
+ {
+ var entityExtensionDto = new EntityExtensionDto
+ {
+ Properties = new Dictionary(),
+ Configuration = new Dictionary()
+ };
+
+ foreach (var propertyConfig in entityConfig.GetProperties())
+ {
+ if (!propertyConfig.IsAvailableToClients)
+ {
+ continue;
+ }
+
+ entityExtensionDto.Properties[propertyConfig.Name] = CreateExtensionPropertyDto(propertyConfig);
+ }
+
+ foreach (var customConfig in entityConfig.Configuration.Where(c => !c.Key.StartsWith("_")))
+ {
+ entityExtensionDto.Configuration[customConfig.Key] = customConfig.Value;
+ }
+
+ return entityExtensionDto;
+ }
+
+ protected virtual ExtensionPropertyDto CreateExtensionPropertyDto(
+ ExtensionPropertyConfiguration propertyConfig)
+ {
+ var extensionPropertyDto = new ExtensionPropertyDto
+ {
+ Type = TypeHelper.GetFullNameHandlingNullableAndGenerics(propertyConfig.Type),
+ TypeSimple = TypeHelper.GetSimplifiedName(propertyConfig.Type),
+ Attributes = new List(),
+ DisplayName = CreateDisplayNameDto(propertyConfig),
+ Configuration = new Dictionary(),
+ Api = new ExtensionPropertyApiDto
+ {
+ OnGet = new ExtensionPropertyApiGetDto
+ {
+ IsAvailable = propertyConfig.Api.OnGet.IsAvailable
+ },
+ OnCreate = new ExtensionPropertyApiCreateDto
+ {
+ IsAvailable = propertyConfig.Api.OnCreate.IsAvailable
+ },
+ OnUpdate = new ExtensionPropertyApiUpdateDto
+ {
+ IsAvailable = propertyConfig.Api.OnUpdate.IsAvailable
+ }
+ },
+ Ui = new ExtensionPropertyUiDto
+ {
+ OnCreateForm = new ExtensionPropertyUiFormDto
+ {
+ IsVisible = propertyConfig.UI.OnCreateForm.IsVisible
+ },
+ OnEditForm = new ExtensionPropertyUiFormDto
+ {
+ IsVisible = propertyConfig.UI.OnEditForm.IsVisible
+ },
+ OnTable = new ExtensionPropertyUiTableDto
+ {
+ IsVisible = propertyConfig.UI.OnTable.IsVisible
+ }
+ }
+ };
+
+ foreach (var attribute in propertyConfig.Attributes)
+ {
+ extensionPropertyDto.Attributes.Add(
+ ExtensionPropertyAttributeDto.Create(attribute)
+ );
+ }
+
+ foreach (var customConfig in propertyConfig.Configuration.Where(c => !c.Key.StartsWith("_")))
+ {
+ extensionPropertyDto.Configuration[customConfig.Key] = customConfig.Value;
+ }
+
+ return extensionPropertyDto;
+ }
+
+ protected virtual LocalizableStringDto CreateDisplayNameDto(ExtensionPropertyConfiguration propertyConfig)
+ {
+ if (propertyConfig.DisplayName == null)
+ {
+ return null;
+ }
+
+ if (propertyConfig.DisplayName is LocalizableString localizableStringInstance)
+ {
+ return new LocalizableStringDto(
+ localizableStringInstance.Name,
+ localizableStringInstance.ResourceType != null
+ ? LocalizationResourceNameAttribute.GetName(localizableStringInstance.ResourceType)
+ : null
+ );
+ }
+
+ if (propertyConfig.DisplayName is FixedLocalizableString fixedLocalizableString)
+ {
+ // "_" means don't use the default resource, but directly use the name.
+ return new LocalizableStringDto(fixedLocalizableString.Value, "_");
+ }
+
+ return null;
+ }
+ }
+}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/EntityExtensionDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/EntityExtensionDto.cs
new file mode 100644
index 0000000000..83093e0370
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/EntityExtensionDto.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+
+namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending
+{
+ [Serializable]
+ public class EntityExtensionDto
+ {
+ public Dictionary Properties { get; set; }
+
+ public Dictionary Configuration { get; set; }
+
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyApiCreateDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyApiCreateDto.cs
new file mode 100644
index 0000000000..a2a588a358
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyApiCreateDto.cs
@@ -0,0 +1,13 @@
+using System;
+
+namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending
+{
+ [Serializable]
+ public class ExtensionPropertyApiCreateDto
+ {
+ ///
+ /// Default: true.
+ ///
+ public bool IsAvailable { get; set; } = true;
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyApiDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyApiDto.cs
new file mode 100644
index 0000000000..a9b4ec5b24
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyApiDto.cs
@@ -0,0 +1,23 @@
+using JetBrains.Annotations;
+
+namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending
+{
+ public class ExtensionPropertyApiDto
+ {
+ [NotNull]
+ public ExtensionPropertyApiGetDto OnGet { get; set; }
+
+ [NotNull]
+ public ExtensionPropertyApiCreateDto OnCreate { get; set; }
+
+ [NotNull]
+ public ExtensionPropertyApiUpdateDto OnUpdate { get; set; }
+
+ public ExtensionPropertyApiDto()
+ {
+ OnGet = new ExtensionPropertyApiGetDto();
+ OnCreate = new ExtensionPropertyApiCreateDto();
+ OnUpdate = new ExtensionPropertyApiUpdateDto();
+ }
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyApiGetDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyApiGetDto.cs
new file mode 100644
index 0000000000..e50a45d15a
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyApiGetDto.cs
@@ -0,0 +1,13 @@
+using System;
+
+namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending
+{
+ [Serializable]
+ public class ExtensionPropertyApiGetDto
+ {
+ ///
+ /// Default: true.
+ ///
+ public bool IsAvailable { get; set; } = true;
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyApiUpdateDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyApiUpdateDto.cs
new file mode 100644
index 0000000000..a517b258da
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyApiUpdateDto.cs
@@ -0,0 +1,13 @@
+using System;
+
+namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending
+{
+ [Serializable]
+ public class ExtensionPropertyApiUpdateDto
+ {
+ ///
+ /// Default: true.
+ ///
+ public bool IsAvailable { get; set; } = true;
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyAttributeDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyAttributeDto.cs
new file mode 100644
index 0000000000..c1c19350c2
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyAttributeDto.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using Volo.Abp.Reflection;
+
+namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending
+{
+ [Serializable]
+ public class ExtensionPropertyAttributeDto
+ {
+ public string Type { get; set; }
+ public string TypeSimple { get; set; }
+ public Dictionary Configuration { get; set; }
+
+ public static ExtensionPropertyAttributeDto Create(Attribute attribute)
+ {
+ var attributeType = attribute.GetType();
+ var dto = new ExtensionPropertyAttributeDto
+ {
+ Type = TypeHelper.GetFullNameHandlingNullableAndGenerics(attributeType),
+ TypeSimple = TypeHelper.GetSimplifiedName(attributeType),
+ Configuration = new Dictionary()
+ };
+
+ if (attribute is StringLengthAttribute stringLengthAttribute)
+ {
+ dto.Configuration["MaximumLength"] = stringLengthAttribute.MaximumLength;
+ dto.Configuration["MinimumLength"] = stringLengthAttribute.MinimumLength;
+ }
+
+ //TODO: Others!
+
+ return dto;
+ }
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyDto.cs
new file mode 100644
index 0000000000..74214914b9
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyDto.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using JetBrains.Annotations;
+
+namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending
+{
+ [Serializable]
+ public class ExtensionPropertyDto
+ {
+ public string Type { get; set; }
+
+ public string TypeSimple { get; set; }
+
+ [CanBeNull]
+ public LocalizableStringDto DisplayName { get; set; }
+
+ public ExtensionPropertyApiDto Api { get; set; }
+
+ public ExtensionPropertyUiDto Ui { get; set; }
+
+ public List Attributes { get; set; }
+
+ public Dictionary Configuration { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyUiDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyUiDto.cs
new file mode 100644
index 0000000000..2fb841ec5a
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyUiDto.cs
@@ -0,0 +1,12 @@
+using System;
+
+namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending
+{
+ [Serializable]
+ public class ExtensionPropertyUiDto
+ {
+ public ExtensionPropertyUiTableDto OnTable { get; set; }
+ public ExtensionPropertyUiFormDto OnCreateForm { get; set; }
+ public ExtensionPropertyUiFormDto OnEditForm { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyUiFormDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyUiFormDto.cs
new file mode 100644
index 0000000000..c4f6f5211c
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyUiFormDto.cs
@@ -0,0 +1,10 @@
+using System;
+
+namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending
+{
+ [Serializable]
+ public class ExtensionPropertyUiFormDto
+ {
+ public bool IsVisible { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyUiTableDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyUiTableDto.cs
new file mode 100644
index 0000000000..4c9e4a7ce0
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyUiTableDto.cs
@@ -0,0 +1,10 @@
+using System;
+
+namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending
+{
+ [Serializable]
+ public class ExtensionPropertyUiTableDto
+ {
+ public bool IsVisible { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ICachedObjectExtensionsDtoService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ICachedObjectExtensionsDtoService.cs
new file mode 100644
index 0000000000..f0163c8b55
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ICachedObjectExtensionsDtoService.cs
@@ -0,0 +1,7 @@
+namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending
+{
+ public interface ICachedObjectExtensionsDtoService
+ {
+ ObjectExtensionsDto Get();
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/LocalizableStringDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/LocalizableStringDto.cs
new file mode 100644
index 0000000000..b80352d791
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/LocalizableStringDto.cs
@@ -0,0 +1,21 @@
+using System;
+using JetBrains.Annotations;
+
+namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending
+{
+ [Serializable]
+ public class LocalizableStringDto
+ {
+ [NotNull]
+ public string Name { get; private set; }
+
+ [CanBeNull]
+ public string Resource { get; set; }
+
+ public LocalizableStringDto([NotNull] string name, string resource = null)
+ {
+ Name = Check.NotNullOrEmpty(name, nameof(name));
+ Resource = resource;
+ }
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ObjectExtensionConfigurationDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ObjectExtensionConfigurationDto.cs
new file mode 100644
index 0000000000..e077596f59
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ObjectExtensionConfigurationDto.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+
+namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending
+{
+ [Serializable]
+ public class ModuleExtensionDto
+ {
+ public Dictionary Entities { get; set; }
+
+ public Dictionary Configuration { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ObjectExtensionsDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ObjectExtensionsDto.cs
new file mode 100644
index 0000000000..fd9665eab1
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ObjectExtensionsDto.cs
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+
+namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending
+{
+ [Serializable]
+ public class ObjectExtensionsDto
+ {
+ public Dictionary Modules { get; set; }
+ }
+}
\ No newline at end of file
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..4504906566 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);
@@ -142,6 +144,13 @@ 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)
{
@@ -152,7 +161,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/AbpInputTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpInputTagHelper.cs
index 10ce263032..f264d21cd5 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpInputTagHelper.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpInputTagHelper.cs
@@ -21,6 +21,9 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
public bool AutoFocus { get; set; }
+ [HtmlAttributeName("type")]
+ public string InputTypeName { get; set; }
+
public AbpFormControlSize Size { get; set; } = AbpFormControlSize.Default;
[HtmlAttributeName("required-symbol")]
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..a2bb92a14d 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);
@@ -117,6 +117,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
return new InputTagHelper(_generator)
{
For = TagHelper.AspFor,
+ InputTypeName = TagHelper.InputTypeName,
ViewContext = TagHelper.ViewContext
};
}
@@ -161,7 +162,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 +171,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", "");
@@ -331,6 +332,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
var groupPrefix = "group-";
var tagHelperAttributes = output.Attributes.Where(a => !a.Name.StartsWith(groupPrefix)).ToList();
+
var attrList = new TagHelperAttributeList();
foreach (var tagHelperAttribute in tagHelperAttributes)
@@ -338,6 +340,11 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
attrList.Add(tagHelperAttribute);
}
+ if (!TagHelper.InputTypeName.IsNullOrEmpty() && !attrList.ContainsName("type"))
+ {
+ attrList.Add("type", TagHelper.InputTypeName);
+ }
+
return attrList;
}
@@ -400,9 +407,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/Pages/Abp/MultiTenancy/AbpTenantController.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Pages/Abp/MultiTenancy/AbpTenantController.cs
index b84ffc421f..768a3331f3 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Pages/Abp/MultiTenancy/AbpTenantController.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Pages/Abp/MultiTenancy/AbpTenantController.cs
@@ -1,11 +1,14 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
+using Volo.Abp;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc.MultiTenancy;
namespace Pages.Abp.MultiTenancy
{
+ [Area("abp")]
+ [RemoteService(Name = "abp")]
[Route("api/abp/multi-tenancy")]
public class AbpTenantController : AbpController, IAbpTenantAppService
{
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/de.json b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/de.json
new file mode 100644
index 0000000000..98909d9847
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/de.json
@@ -0,0 +1,12 @@
+{
+ "culture": "de",
+ "texts": {
+ "GivenTenantIsNotAvailable": "Der angegebene Mandant ist nicht verfügbar: {0}",
+ "Tenant": "Mandant",
+ "Switch": "wechseln",
+ "Name": "Name",
+ "SwitchTenantHint": "Lassen Sie das Namensfeld leer, um auf die Host-Seite zu wechseln.",
+ "SwitchTenant": "Mandant wechseln",
+ "NotSelected": "Nicht ausgewählt"
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/nl.json b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/nl.json
new file mode 100644
index 0000000000..2e3971055e
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/nl.json
@@ -0,0 +1,12 @@
+{
+ "culture": "nl",
+ "texts": {
+ "GivenTenantIsNotAvailable": "Gegeven klant is niet beschikbaar: {0}",
+ "Tenant": "Klant",
+ "Switch": "Schakel over",
+ "Name": "Name",
+ "SwitchTenantHint": "Laat het naamveld leeg om over te schakelen naar de hostkant.",
+ "SwitchTenant": "Klant wisselen",
+ "NotSelected": "Niet geselecteerd"
+ }
+}
\ 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.AspNetCore.Mvc.UI.Theme.Shared/Bundling/SharedThemeGlobalScriptContributor.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Bundling/SharedThemeGlobalScriptContributor.cs
index 0f4cc752c9..892f0d497a 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Bundling/SharedThemeGlobalScriptContributor.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Bundling/SharedThemeGlobalScriptContributor.cs
@@ -36,6 +36,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Bundling
{
context.Files.AddRange(new[]
{
+ "/libs/abp/aspnetcore-mvc-ui-theme-shared/ui-extensions.js",
"/libs/abp/aspnetcore-mvc-ui-theme-shared/jquery/jquery-extensions.js",
"/libs/abp/aspnetcore-mvc-ui-theme-shared/jquery-form/jquery-form-extensions.js",
"/libs/abp/aspnetcore-mvc-ui-theme-shared/jquery/widget-manager.js",
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Components/DefaultBrandingProvider.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Components/DefaultBrandingProvider.cs
index eb13a1cea0..a85c03364c 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Components/DefaultBrandingProvider.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Components/DefaultBrandingProvider.cs
@@ -7,5 +7,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Components
public virtual string AppName => "MyApplication";
public virtual string LogoUrl => null;
+
+ public virtual string LogoReverseUrl => null;
}
}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Components/IBrandingProvider.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Components/IBrandingProvider.cs
index 65e3cb8883..1c20f7fc6e 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Components/IBrandingProvider.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Components/IBrandingProvider.cs
@@ -4,6 +4,14 @@
{
string AppName { get; }
+ ///
+ /// Logo on white background
+ ///
string LogoUrl { get; }
+
+ ///
+ /// Logo on dark background
+ ///
+ string LogoReverseUrl { get; }
}
}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/AbpPageToolbarOptions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/AbpPageToolbarOptions.cs
new file mode 100644
index 0000000000..f033fbaeab
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/AbpPageToolbarOptions.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using JetBrains.Annotations;
+
+namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.PageToolbars
+{
+ public class AbpPageToolbarOptions
+ {
+ public PageToolbarDictionary Toolbars { get; }
+
+ public AbpPageToolbarOptions()
+ {
+ Toolbars = new PageToolbarDictionary();
+ }
+
+ public void Configure([NotNull] Action configureAction)
+ {
+ // ReSharper disable once AssignNullToNotNullAttribute
+ Configure(typeof(TPage).FullName, configureAction);
+ }
+
+ public void Configure([NotNull]string pageName, [NotNull]Action configureAction)
+ {
+ Check.NotNullOrWhiteSpace(pageName, nameof(pageName));
+ Check.NotNull(configureAction, nameof(configureAction));
+
+ var toolbar = Toolbars.GetOrAdd(pageName, () => new PageToolbar(pageName));
+ configureAction(toolbar);
+ }
+ }
+}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/IPageToolbarContributor.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/IPageToolbarContributor.cs
new file mode 100644
index 0000000000..1b373025b6
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/IPageToolbarContributor.cs
@@ -0,0 +1,9 @@
+using System.Threading.Tasks;
+
+namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.PageToolbars
+{
+ public interface IPageToolbarContributor
+ {
+ Task ContributeAsync(PageToolbarContributionContext context);
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/IPageToolbarManager.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/IPageToolbarManager.cs
new file mode 100644
index 0000000000..1a638e8901
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/IPageToolbarManager.cs
@@ -0,0 +1,9 @@
+using System.Threading.Tasks;
+
+namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.PageToolbars
+{
+ public interface IPageToolbarManager
+ {
+ Task GetItemsAsync(string pageName);
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/PageToolbar.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/PageToolbar.cs
new file mode 100644
index 0000000000..7362e54074
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/PageToolbar.cs
@@ -0,0 +1,17 @@
+using JetBrains.Annotations;
+
+namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.PageToolbars
+{
+ public class PageToolbar
+ {
+ public string PageName { get; }
+
+ public PageToolbarContributorList Contributors { get; set; }
+
+ public PageToolbar([NotNull] string pageName)
+ {
+ PageName = Check.NotNullOrEmpty(pageName, nameof(pageName));
+ Contributors = new PageToolbarContributorList();
+ }
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/PageToolbarContributionContext.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/PageToolbarContributionContext.cs
new file mode 100644
index 0000000000..2203559add
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/PageToolbarContributionContext.cs
@@ -0,0 +1,27 @@
+using System;
+using JetBrains.Annotations;
+
+namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.PageToolbars
+{
+ public class PageToolbarContributionContext
+ {
+ [NotNull]
+ public string PageName { get; }
+
+ [NotNull]
+ public IServiceProvider ServiceProvider { get; }
+
+ [NotNull]
+ public PageToolbarItemList Items { get; }
+
+ public PageToolbarContributionContext(
+ [NotNull] string pageName,
+ [NotNull] IServiceProvider serviceProvider)
+ {
+ PageName = Check.NotNull(pageName, nameof(pageName));
+ ServiceProvider = Check.NotNull(serviceProvider, nameof(serviceProvider));
+
+ Items = new PageToolbarItemList();
+ }
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/PageToolbarContributor.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/PageToolbarContributor.cs
new file mode 100644
index 0000000000..2cff729aa0
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/PageToolbarContributor.cs
@@ -0,0 +1,9 @@
+using System.Threading.Tasks;
+
+namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.PageToolbars
+{
+ public abstract class PageToolbarContributor : IPageToolbarContributor
+ {
+ public abstract Task ContributeAsync(PageToolbarContributionContext context);
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/PageToolbarContributorList.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/PageToolbarContributorList.cs
new file mode 100644
index 0000000000..e1c7c09934
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/PageToolbarContributorList.cs
@@ -0,0 +1,8 @@
+using System.Collections.Generic;
+
+namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.PageToolbars
+{
+ public class PageToolbarContributorList : List
+ {
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/PageToolbarDictionary.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/PageToolbarDictionary.cs
new file mode 100644
index 0000000000..30a868c5b1
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/PageToolbarDictionary.cs
@@ -0,0 +1,9 @@
+using System.Collections.Generic;
+
+namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.PageToolbars
+{
+ public class PageToolbarDictionary : Dictionary
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/PageToolbarExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/PageToolbarExtensions.cs
new file mode 100644
index 0000000000..794b923b48
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/PageToolbarExtensions.cs
@@ -0,0 +1,84 @@
+using System;
+using Localization.Resources.AbpUi;
+using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers;
+using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button;
+using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Pages.Shared.Components.AbpPageToolbar.Button;
+using Volo.Abp.Localization;
+
+namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.PageToolbars
+{
+ public static class PageToolbarExtensions
+ {
+ public static PageToolbar AddComponent(
+ this PageToolbar toolbar,
+ object argument = null,
+ int order = 0,
+ string requiredPolicyName = null)
+ {
+ return toolbar.AddComponent(
+ typeof(TComponent),
+ argument,
+ order,
+ requiredPolicyName
+ );
+ }
+
+ public static PageToolbar AddComponent(
+ this PageToolbar toolbar,
+ Type componentType,
+ object argument = null,
+ int order = 0,
+ string requiredPolicyName = null)
+ {
+ toolbar.Contributors.Add(
+ new SimplePageToolbarContributor(
+ componentType,
+ argument,
+ order,
+ requiredPolicyName
+ )
+ );
+
+ return toolbar;
+ }
+
+ public static PageToolbar AddButton(
+ this PageToolbar toolbar,
+ ILocalizableString text,
+ string icon = null,
+ string name = null,
+ string id = null,
+ ILocalizableString busyText = null,
+ FontIconType iconType = FontIconType.FontAwesome,
+ AbpButtonType type = AbpButtonType.Primary,
+ AbpButtonSize size = AbpButtonSize.Small,
+ bool disabled = false,
+ int order = 0,
+ string requiredPolicyName = null)
+ {
+ if (busyText == null)
+ {
+ busyText = new LocalizableString(typeof(AbpUiResource), "ProcessingWithThreeDot");
+ }
+
+ toolbar.AddComponent(
+ new
+ {
+ text,
+ icon,
+ name,
+ id,
+ busyText,
+ iconType,
+ type,
+ size,
+ disabled
+ },
+ order,
+ requiredPolicyName
+ );
+
+ return toolbar;
+ }
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/PageToolbarItem.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/PageToolbarItem.cs
new file mode 100644
index 0000000000..b73dc4d829
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/PageToolbarItem.cs
@@ -0,0 +1,26 @@
+using System;
+using JetBrains.Annotations;
+
+namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.PageToolbars
+{
+ public class PageToolbarItem
+ {
+ [NotNull]
+ public Type ComponentType { get; }
+
+ [CanBeNull]
+ public object Arguments { get; set; }
+
+ public int Order { get; set; }
+
+ public PageToolbarItem(
+ [NotNull] Type componentType,
+ [CanBeNull] object arguments = null,
+ int order = 0)
+ {
+ ComponentType = Check.NotNull(componentType, nameof(componentType));
+ Arguments = arguments;
+ Order = order;
+ }
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/PageToolbarItemList.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/PageToolbarItemList.cs
new file mode 100644
index 0000000000..69b943d376
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/PageToolbarItemList.cs
@@ -0,0 +1,9 @@
+using System.Collections.Generic;
+
+namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.PageToolbars
+{
+ public class PageToolbarItemList : List
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/PageToolbarManager.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/PageToolbarManager.cs
new file mode 100644
index 0000000000..f54365674f
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/PageToolbarManager.cs
@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Microsoft.Extensions.Options;
+using Volo.Abp.DependencyInjection;
+
+namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.PageToolbars
+{
+ public class PageToolbarManager : IPageToolbarManager, ITransientDependency
+ {
+ protected AbpPageToolbarOptions Options { get; }
+ protected IHybridServiceScopeFactory ServiceScopeFactory { get; }
+
+ public PageToolbarManager(
+ IOptions options,
+ IHybridServiceScopeFactory serviceScopeFactory)
+ {
+ Options = options.Value;
+ ServiceScopeFactory = serviceScopeFactory;
+ }
+
+ public virtual async Task GetItemsAsync(string pageName)
+ {
+ var toolbar = Options.Toolbars.GetOrDefault(pageName);
+ if (toolbar == null || !toolbar.Contributors.Any())
+ {
+ return Array.Empty();
+ }
+
+ using (var scope = ServiceScopeFactory.CreateScope())
+ {
+ var context = new PageToolbarContributionContext(pageName, scope.ServiceProvider);
+
+ foreach (var contributor in toolbar.Contributors)
+ {
+ await contributor.ContributeAsync(context);
+ }
+
+ return context.Items.OrderBy(i => i.Order).ToArray();
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/SimplePageToolbarContributor.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/SimplePageToolbarContributor.cs
new file mode 100644
index 0000000000..a07b357b42
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/SimplePageToolbarContributor.cs
@@ -0,0 +1,52 @@
+using System;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.Extensions.DependencyInjection;
+
+namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.PageToolbars
+{
+ public class SimplePageToolbarContributor : IPageToolbarContributor
+ {
+ public Type ComponentType { get; }
+
+ public object Argument { get; set; }
+
+ public int Order { get; }
+
+ public string RequiredPolicyName { get; }
+
+ public SimplePageToolbarContributor(
+ Type componentType,
+ object argument = null,
+ int order = 0,
+ string requiredPolicyName = null)
+ {
+ ComponentType = componentType;
+ Argument = argument;
+ Order = order;
+ RequiredPolicyName = requiredPolicyName;
+ }
+
+ public async Task ContributeAsync(PageToolbarContributionContext context)
+ {
+ if(await ShouldAddComponentAsync(context))
+ {
+ context.Items.Add(new PageToolbarItem(ComponentType, Argument, Order));
+ }
+ }
+
+ protected virtual async Task ShouldAddComponentAsync(PageToolbarContributionContext context)
+ {
+ if (RequiredPolicyName != null)
+ {
+ var authorizationService = context.ServiceProvider.GetRequiredService();
+ if (!await authorizationService.IsGrantedAsync(RequiredPolicyName))
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpPageToolbar/AbpPageToolbarViewComponent.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpPageToolbar/AbpPageToolbarViewComponent.cs
new file mode 100644
index 0000000000..b07bc69abb
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpPageToolbar/AbpPageToolbarViewComponent.cs
@@ -0,0 +1,22 @@
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Mvc;
+using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.PageToolbars;
+
+namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Pages.Shared.Components.AbpPageToolbar
+{
+ public class AbpPageToolbarViewComponent : AbpViewComponent
+ {
+ private readonly IPageToolbarManager _toolbarManager;
+
+ public AbpPageToolbarViewComponent(IPageToolbarManager toolbarManager)
+ {
+ _toolbarManager = toolbarManager;
+ }
+
+ public async Task InvokeAsync(string pageName)
+ {
+ var items = await _toolbarManager.GetItemsAsync(pageName);
+ return View("~/Pages/Shared/Components/AbpPageToolbar/Default.cshtml", items);
+ }
+ }
+}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpPageToolbar/Button/AbpPageToolbarButtonViewComponent.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpPageToolbar/Button/AbpPageToolbarButtonViewComponent.cs
new file mode 100644
index 0000000000..894ade7005
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpPageToolbar/Button/AbpPageToolbarButtonViewComponent.cs
@@ -0,0 +1,82 @@
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Localization;
+using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers;
+using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button;
+using Volo.Abp.Localization;
+
+namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Pages.Shared.Components.AbpPageToolbar.Button
+{
+ public class AbpPageToolbarButtonViewComponent : AbpViewComponent
+ {
+ protected IStringLocalizerFactory StringLocalizerFactory { get; }
+
+ public AbpPageToolbarButtonViewComponent(IStringLocalizerFactory stringLocalizerFactory)
+ {
+ StringLocalizerFactory = stringLocalizerFactory;
+ }
+
+ public IViewComponentResult Invoke(
+ ILocalizableString text,
+ string name,
+ string icon,
+ string id,
+ ILocalizableString busyText,
+ FontIconType iconType,
+ AbpButtonType type,
+ AbpButtonSize size,
+ bool disabled)
+ {
+ Check.NotNull(text, nameof(text));
+
+ return View(
+ "~/Pages/Shared/Components/AbpPageToolbar/Button/Default.cshtml",
+ new AbpPageToolbarButtonViewModel(
+ text.Localize(StringLocalizerFactory),
+ name,
+ icon,
+ id,
+ busyText?.Localize(StringLocalizerFactory),
+ iconType,
+ type,
+ size,
+ disabled
+ )
+ );
+ }
+
+ public class AbpPageToolbarButtonViewModel
+ {
+ public string Text { get; }
+ public string Name { get; }
+ public string Icon { get; }
+ public string Id { get; }
+ public string BusyText { get; }
+ public FontIconType IconType { get; }
+ public AbpButtonType Type { get; }
+ public AbpButtonSize Size { get; }
+ public bool Disabled { get; }
+
+ public AbpPageToolbarButtonViewModel(
+ string text,
+ string name,
+ string icon,
+ string id,
+ string busyText,
+ FontIconType iconType,
+ AbpButtonType type,
+ AbpButtonSize size,
+ bool disabled)
+ {
+ Text = text;
+ Name = name;
+ Icon = icon;
+ Id = id;
+ BusyText = busyText;
+ IconType = iconType;
+ Type = type;
+ Size = size;
+ Disabled = disabled;
+ }
+ }
+ }
+}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpPageToolbar/Button/Default.cshtml b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpPageToolbar/Button/Default.cshtml
new file mode 100644
index 0000000000..10f2f7ceb2
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpPageToolbar/Button/Default.cshtml
@@ -0,0 +1,13 @@
+@model Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Pages.Shared.Components.AbpPageToolbar.Button.AbpPageToolbarButtonViewComponent.AbpPageToolbarButtonViewModel
+
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpPageToolbar/Default.cshtml b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpPageToolbar/Default.cshtml
new file mode 100644
index 0000000000..a5331abc9e
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpPageToolbar/Default.cshtml
@@ -0,0 +1,5 @@
+@model Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.PageToolbars.PageToolbarItem[]
+@foreach (var toolbarItem in Model)
+{
+ @(await Component.InvokeAsync(toolbarItem.ComponentType, toolbarItem.Arguments))
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpPageToolbar/_ViewImports.cshtml b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpPageToolbar/_ViewImports.cshtml
new file mode 100644
index 0000000000..c1da1f5f10
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpPageToolbar/_ViewImports.cshtml
@@ -0,0 +1,4 @@
+@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
+@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI
+@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bootstrap
+@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bundling
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/datatables/datatables-extensions.js b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/datatables/datatables-extensions.js
index 77cae54b67..cd31e73bc4 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/datatables/datatables-extensions.js
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/datatables/datatables-extensions.js
@@ -1,60 +1,16 @@
-var abp = abp;
-
+var abp = abp || {};
(function ($) {
- /************************************************************************
- * RECORD-ACTIONS extension for datatables
- ---------------------------------------------------------------
- * SINGLE BUTTON USAGE (creates the given JQuery element)
- {
- targets: 0, //optional
- rowAction:
- {
- element: $("")
- .addClass("btn btn-primary btn-sm m-btn--icon")
- .text("My button")
- .prepend($("").addClass("la la-sign-in"))
- .click(function () {
- console.log($(this).data());
- })
- },
- },
-
- ---------------------------------------------------------------
- * LIST OF ITEMS USAGE
- {
- targets: 0, //optional
- rowAction:
- {
- text: 'My actions', //optional. default value: Actions
- icon: 'bolt' //optional. default value: cog. See fa icon set https://fontawesome.com/v4.7.0/icons/
- items:
- [
- {
- text: "My first action", //mandatory
- icon: "thumbs-o-down", //optional.
- visible: true //optional. default value: true. Accepts boolean returning function too. Eg: function(){ return true/false;} ,
- action: function (data) {
- console.log(data.record);
- }
- },
- {
- text: "My second action",
- icon: "thumbs-o-up",
- visible: true,
- action: function (data) {
- console.log(data.record);
- }
- }
- ]
- }
- },
- *************************************************************************/
+ var datatables = abp.utils.createNamespace(abp, 'libs.datatables');
+
var localize = function (key) {
return abp.localization.getResource('AbpUi')(key);
};
- var recordActions = function () {
+ /************************************************************************
+ * RECORD-ACTIONS extension for datatables *
+ *************************************************************************/
+ (function () {
if (!$.fn.dataTableExt) {
return;
}
@@ -117,7 +73,7 @@
.addClass('action-button');
var $dropdownButton = $('');
-
+
if (field.icon !== undefined) {
if (field.icon) {
$dropdownButton.append($("").addClass("fa fa-" + field.icon + " mr-1"));
@@ -267,14 +223,12 @@
}
});
- }();
+ })();
/************************************************************************
* AJAX extension for datatables *
*************************************************************************/
- var datatables = abp.utils.createNamespace(abp, 'libs.datatables');
-
- var ajaxActions = function () {
+ (function () {
datatables.createAjax = function (serverMethod, inputAction) {
return function (requestData, callback, settings) {
var input = inputAction ? inputAction() : {};
@@ -318,14 +272,14 @@
}
};
};
- }();
+ })();
/************************************************************************
* Configuration/Options normalizer for datatables *
*************************************************************************/
- var optionNormalizer = function () {
+ (function () {
- var customizeRowActionColumn = function(column) {
+ var customizeRowActionColumn = function (column) {
column.data = null;
column.orderable = false;
column.defaultContent = "";
@@ -336,6 +290,9 @@
};
datatables.normalizeConfiguration = function (configuration) {
+
+ configuration.scrollX = true;
+
for (var i = 0; i < configuration.columnDefs.length; i++) {
var column = configuration.columnDefs[i];
if (!column.targets) {
@@ -369,6 +326,6 @@
return configuration;
};
- }();
+ })();
})(jQuery);
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/ui-extensions.js b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/ui-extensions.js
new file mode 100644
index 0000000000..9ee545615c
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/ui-extensions.js
@@ -0,0 +1,193 @@
+var abp = abp || {};
+(function () {
+ abp.ui = abp.ui || {};
+ abp.ui.extensions = abp.ui.extensions || {};
+
+ abp.ui.extensions.ActionList = function () {
+ return new abp.utils.common.LinkedList();
+ };
+
+ abp.ui.extensions.ColumnList = function () {
+ return new abp.utils.common.LinkedList();
+ };
+
+ abp.ui.extensions.entityActions = (function () {
+ var _callbackLists = {};
+
+ function _get(name) {
+ var callbackList = _callbackLists[name];
+
+ if (!callbackList) {
+ callbackList = _callbackLists[name] = [];
+ }
+
+ return {
+ addContributor: _addContributor,
+ get actions() {
+ return _getActions();
+ }
+ };
+
+ function _addContributor(contributeCallback, order) {
+ if (order === undefined || order >= callbackList.length) {
+ callbackList.push(contributeCallback);
+ } else if (order === 0) {
+ callbackList.unshift(contributeCallback);
+ } else {
+ callbackList.splice(order, 0, contributeCallback);
+ }
+ }
+
+ function _getActions() {
+ var actionList = new abp.ui.extensions.ActionList();
+
+ callbackList.forEach(function (callback) {
+ callback(actionList);
+ });
+
+ return actionList;
+ }
+ }
+
+ return {
+ get: _get
+ };
+ })();
+
+ abp.ui.extensions.tableColumns = (function () {
+ var _callbackLists = {};
+
+ function _get(name) {
+ var callbackList = _callbackLists[name];
+
+ if (!callbackList) {
+ callbackList = _callbackLists[name] = [];
+ }
+
+ return {
+ addContributor: _addContributor,
+ get columns() {
+ return _getColumns();
+ }
+ };
+
+ function _addContributor(contributeCallback, order) {
+ if (order === undefined || order >= callbackList.length) {
+ callbackList.push(contributeCallback);
+ } else if (order === 0) {
+ callbackList.unshift(contributeCallback);
+ } else {
+ callbackList.splice(order, 0, contributeCallback);
+ }
+ }
+
+ function _getColumns() {
+ var columnList = new abp.ui.extensions.ColumnList();
+
+ callbackList.forEach(function (callback) {
+ callback(columnList);
+ });
+
+ return columnList;
+ }
+ }
+
+ return {
+ get: _get
+ };
+ })();
+
+ function initializeObjectExtensions() {
+
+ function localizeDisplayName(propertyName, displayName) {
+ if (displayName && displayName.name) {
+ return abp.localization.localize(displayName.name, displayName.resource);
+ }
+
+ if (abp.localization.isLocalized('DisplayName:' + propertyName)) {
+ return abp.localization.localize('DisplayName:' + propertyName);
+ }
+
+ return abp.localization.localize(propertyName);
+ }
+
+ function configureTableColumns(tableName, columnConfigs) {
+ abp.ui.extensions.tableColumns.get(tableName)
+ .addContributor(
+ function (columnList) {
+ columnList.addManyTail(columnConfigs);
+ }
+ );
+ }
+
+ function getTableProperties(objectConfig) {
+ var propertyNames = Object.keys(objectConfig.properties);
+ var tableProperties = [];
+ for (var i = 0; i < propertyNames.length; i++) {
+ var propertyName = propertyNames[i];
+ var propertyConfig = objectConfig.properties[propertyName];
+ if (propertyConfig.ui.onTable.isVisible) {
+ tableProperties.push({
+ name: propertyName,
+ config: propertyConfig
+ });
+ }
+ }
+
+ return tableProperties;
+ }
+
+ function convertPropertiesToColumnConfigs(properties) {
+ var columnConfigs = [];
+
+ for (var i = 0; i < properties.length; i++) {
+ var tableProperty = properties[i];
+ columnConfigs.push({
+ title: localizeDisplayName(tableProperty.name, tableProperty.config.displayName),
+ data: "extraProperties." + tableProperty.name,
+ orderable: false
+ });
+ }
+
+ return columnConfigs;
+ }
+
+ function configureEntity(moduleName, entityName, entityConfig) {
+ var tableProperties = getTableProperties(entityConfig);
+
+ if (tableProperties.length > 0) {
+ var tableName = abp.utils.toCamelCase(moduleName) + "." + abp.utils.toCamelCase(entityName);
+ var columnConfigs = convertPropertiesToColumnConfigs(tableProperties);
+ configureTableColumns(
+ tableName,
+ columnConfigs
+ );
+ }
+ }
+
+ function configureModule(moduleName, moduleConfig) {
+ var entityNames = Object.keys(moduleConfig.entities);
+ for (var i = 0; i < entityNames.length; i++) {
+ configureEntity(
+ moduleName,
+ entityNames[i],
+ moduleConfig.entities[entityNames[i]]
+ );
+ }
+ }
+
+ var moduleNames = Object.keys(abp.objectExtensions.modules);
+
+ for (var i = 0; i < moduleNames.length; i++) {
+ configureModule(
+ moduleNames[i],
+ abp.objectExtensions.modules[moduleNames[i]]
+ );
+ }
+ }
+
+ abp.event.on('abp.configurationInitialized', function () {
+ initializeObjectExtensions();
+ });
+
+})();
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcModule.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcModule.cs
index 7e469f4195..00ba8423b3 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcModule.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcModule.cs
@@ -18,6 +18,7 @@ using Microsoft.AspNetCore.Mvc.Razor;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure;
using Microsoft.Extensions.Hosting;
+using Microsoft.Extensions.Localization;
using Volo.Abp.ApiVersioning;
using Volo.Abp.AspNetCore.Mvc.ApiExploring;
using Volo.Abp.AspNetCore.Mvc.Conventions;
@@ -90,8 +91,11 @@ namespace Volo.Abp.AspNetCore.Mvc
var mvcCoreBuilder = context.Services.AddMvcCore();
context.Services.ExecutePreConfiguredActions(mvcCoreBuilder);
-
- var abpMvcDataAnnotationsLocalizationOptions = context.Services.ExecutePreConfiguredActions(new AbpMvcDataAnnotationsLocalizationOptions());
+
+ var abpMvcDataAnnotationsLocalizationOptions = context.Services
+ .ExecutePreConfiguredActions(
+ new AbpMvcDataAnnotationsLocalizationOptions()
+ );
context.Services
.AddSingleton>(
@@ -111,8 +115,17 @@ namespace Volo.Abp.AspNetCore.Mvc
{
options.DataAnnotationLocalizerProvider = (type, factory) =>
{
- var resourceType = abpMvcDataAnnotationsLocalizationOptions.AssemblyResources.GetOrDefault(type.Assembly);
- return factory.Create(resourceType ?? type);
+ var resourceType = abpMvcDataAnnotationsLocalizationOptions
+ .AssemblyResources
+ .GetOrDefault(type.Assembly);
+
+ if (resourceType != null)
+ {
+ return factory.Create(resourceType);
+ }
+
+ return factory.CreateDefaultOrNull() ??
+ factory.Create(type);
};
})
.AddViewLocalization(); //TODO: How to configure from the application? Also, consider to move to a UI module since APIs does not care about it.
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpMvcOptionsExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpMvcOptionsExtensions.cs
index f1225f1abf..4aa183a43d 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpMvcOptionsExtensions.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpMvcOptionsExtensions.cs
@@ -5,6 +5,7 @@ using Volo.Abp.AspNetCore.Mvc.Conventions;
using Volo.Abp.AspNetCore.Mvc.ExceptionHandling;
using Volo.Abp.AspNetCore.Mvc.Features;
using Volo.Abp.AspNetCore.Mvc.ModelBinding;
+using Volo.Abp.AspNetCore.Mvc.ModelBinding.Metadata;
using Volo.Abp.AspNetCore.Mvc.Response;
using Volo.Abp.AspNetCore.Mvc.Uow;
using Volo.Abp.AspNetCore.Mvc.Validation;
@@ -48,6 +49,7 @@ namespace Volo.Abp.AspNetCore.Mvc
private static void AddModelBinders(MvcOptions options)
{
options.ModelBinderProviders.Insert(0, new AbpDateTimeModelBinderProvider());
+ options.ModelBinderProviders.Insert(0, new AbpExtraPropertiesDictionaryModelBinderProvider());
}
private static void AddMetadataProviders(MvcOptions options, IServiceCollection services)
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApiExploring/AbpApiDefinitionController.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApiExploring/AbpApiDefinitionController.cs
index e1c2d1f859..09807391f6 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApiExploring/AbpApiDefinitionController.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApiExploring/AbpApiDefinitionController.cs
@@ -3,6 +3,8 @@ using Volo.Abp.Http.Modeling;
namespace Volo.Abp.AspNetCore.Mvc.ApiExploring
{
+ [Area("abp")]
+ [RemoteService(Name = "abp")]
[Route("api/abp/api-definition")]
public class AbpApiDefinitionController : AbpController, IRemoteService
{
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs
index 4b4cf521c2..98fd94882d 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs
@@ -8,6 +8,7 @@ using System.Globalization;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Volo.Abp.Application.Services;
+using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending;
using Volo.Abp.AspNetCore.Mvc.MultiTenancy;
using Volo.Abp.Authorization;
using Volo.Abp.Features;
@@ -30,6 +31,7 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations
private readonly ISettingDefinitionManager _settingDefinitionManager;
private readonly IFeatureDefinitionManager _featureDefinitionManager;
private readonly ILanguageProvider _languageProvider;
+ private readonly ICachedObjectExtensionsDtoService _cachedObjectExtensionsDtoService;
public AbpApplicationConfigurationAppService(
IOptions localizationOptions,
@@ -41,7 +43,8 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations
ISettingProvider settingProvider,
ISettingDefinitionManager settingDefinitionManager,
IFeatureDefinitionManager featureDefinitionManager,
- ILanguageProvider languageProvider)
+ ILanguageProvider languageProvider,
+ ICachedObjectExtensionsDtoService cachedObjectExtensionsDtoService)
{
_serviceProvider = serviceProvider;
_abpAuthorizationPolicyProvider = abpAuthorizationPolicyProvider;
@@ -51,6 +54,7 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations
_settingDefinitionManager = settingDefinitionManager;
_featureDefinitionManager = featureDefinitionManager;
_languageProvider = languageProvider;
+ _cachedObjectExtensionsDtoService = cachedObjectExtensionsDtoService;
_localizationOptions = localizationOptions.Value;
_multiTenancyOptions = multiTenancyOptions.Value;
}
@@ -59,7 +63,9 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations
{
//TODO: Optimize & cache..?
- return new ApplicationConfigurationDto
+ Logger.LogDebug("Executing AbpApplicationConfigurationAppService.GetAsync()...");
+
+ var result = new ApplicationConfigurationDto
{
Auth = await GetAuthConfigAsync(),
Features = await GetFeaturesConfigAsync(),
@@ -67,12 +73,16 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations
CurrentUser = GetCurrentUser(),
Setting = await GetSettingConfigAsync(),
MultiTenancy = GetMultiTenancy(),
- CurrentTenant = GetCurrentTenant()
-
+ CurrentTenant = GetCurrentTenant(),
+ ObjectExtensions = _cachedObjectExtensionsDtoService.Get()
};
+
+ Logger.LogDebug("Executed AbpApplicationConfigurationAppService.GetAsync().");
+
+ return result;
}
- protected virtual CurrentTenantDto GetCurrentTenant()
+ protected virtual CurrentTenantDto GetCurrentTenant()
{
return new CurrentTenantDto()
{
@@ -103,35 +113,25 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations
protected virtual async Task GetAuthConfigAsync()
{
- Logger.LogDebug("Executing AbpApplicationConfigurationAppService.GetAuthConfigAsync()");
-
var authConfig = new ApplicationAuthConfigurationDto();
var policyNames = await _abpAuthorizationPolicyProvider.GetPoliciesNamesAsync();
- Logger.LogDebug($"GetPoliciesNamesAsync returns {policyNames.Count} items.");
-
foreach (var policyName in policyNames)
{
authConfig.Policies[policyName] = true;
- Logger.LogDebug($"_authorizationService.IsGrantedAsync? {policyName}");
-
if (await _authorizationService.IsGrantedAsync(policyName))
{
authConfig.GrantedPolicies[policyName] = true;
}
}
- Logger.LogDebug("Executed AbpApplicationConfigurationAppService.GetAuthConfigAsync()");
-
return authConfig;
}
protected virtual async Task GetLocalizationConfigAsync()
{
- Logger.LogDebug("Executing AbpApplicationConfigurationAppService.GetLocalizationConfigAsync()");
-
var localizationConfig = new ApplicationLocalizationConfigurationDto();
localizationConfig.Languages.AddRange(await _languageProvider.GetLanguagesAsync());
@@ -154,7 +154,12 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations
localizationConfig.CurrentCulture = GetCurrentCultureInfo();
- Logger.LogDebug("Executed AbpApplicationConfigurationAppService.GetLocalizationConfigAsync()");
+ if (_localizationOptions.DefaultResourceType != null)
+ {
+ localizationConfig.DefaultResourceName = LocalizationResourceNameAttribute.GetName(
+ _localizationOptions.DefaultResourceType
+ );
+ }
return localizationConfig;
}
@@ -186,8 +191,6 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations
private async Task GetSettingConfigAsync()
{
- Logger.LogDebug("Executing AbpApplicationConfigurationAppService.GetSettingConfigAsync()");
-
var result = new ApplicationSettingConfigurationDto
{
Values = new Dictionary()
@@ -203,15 +206,11 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations
result.Values[settingDefinition.Name] = await _settingProvider.GetOrNullAsync(settingDefinition.Name);
}
- Logger.LogDebug("Executed AbpApplicationConfigurationAppService.GetSettingConfigAsync()");
-
return result;
}
protected virtual async Task GetFeaturesConfigAsync()
{
- Logger.LogDebug("Executing AbpApplicationConfigurationAppService.GetFeaturesConfigAsync()");
-
var result = new ApplicationFeatureConfigurationDto();
foreach (var featureDefinition in _featureDefinitionManager.GetAll())
@@ -224,8 +223,6 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations
result.Values[featureDefinition.Name] = await FeatureChecker.GetOrNullAsync(featureDefinition.Name);
}
- Logger.LogDebug("Executed AbpApplicationConfigurationAppService.GetFeaturesConfigAsync()");
-
return result;
}
}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationController.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationController.cs
index 67672986be..67c373585e 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationController.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationController.cs
@@ -3,6 +3,8 @@ using Microsoft.AspNetCore.Mvc;
namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations
{
+ [Area("abp")]
+ [RemoteService(Name = "abp")]
[Route("api/abp/application-configuration")]
public class AbpApplicationConfigurationController : AbpController, IAbpApplicationConfigurationAppService
{
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationScriptController.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationScriptController.cs
index 6cc01966a5..d4ce99dc12 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationScriptController.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationScriptController.cs
@@ -12,6 +12,8 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations
[Area("Abp")]
[Route("Abp/ApplicationConfigurationScript")]
[DisableAuditing]
+ [RemoteService(false)]
+ [ApiExplorerSettings(IgnoreApi = true)]
public class AbpApplicationConfigurationScriptController : AbpController
{
private readonly IAbpApplicationConfigurationAppService _configurationAppService;
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs
index f957fd894f..1042ee4d08 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs
@@ -206,7 +206,7 @@ namespace Volo.Abp.AspNetCore.Mvc
/* TODO: Add interfaces
*/
- var typeName = ModelingTypeHelper.GetFullNameHandlingNullableAndGenerics(type);
+ var typeName = TypeHelper.GetFullNameHandlingNullableAndGenerics(type);
if (applicationModel.Types.ContainsKey(typeName))
{
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Localization/AbpLanguagesController.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Localization/AbpLanguagesController.cs
index 6428cf485e..3f25eb2f84 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Localization/AbpLanguagesController.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Localization/AbpLanguagesController.cs
@@ -2,18 +2,20 @@
using Microsoft.AspNetCore.Localization;
using Microsoft.AspNetCore.Mvc;
using System;
-using Volo.Abp.Settings;
+using Volo.Abp.Localization;
namespace Volo.Abp.AspNetCore.Mvc.Localization
{
[Area("Abp")]
[Route("Abp/Languages/[action]")]
+ [RemoteService(false)]
+ [ApiExplorerSettings(IgnoreApi = true)]
public class AbpLanguagesController : AbpController
{
[HttpGet]
public IActionResult Switch(string culture, string uiCulture = "", string returnUrl = "")
{
- if (!GlobalizationHelper.IsValidCultureCode(culture))
+ if (!CultureHelper.IsValidCultureCode(culture))
{
throw new AbpException("Unknown language: " + culture + ". It must be a valid culture!");
}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Localization/GlobalizationHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Localization/GlobalizationHelper.cs
deleted file mode 100644
index a84faeb8f9..0000000000
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Localization/GlobalizationHelper.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using System;
-using System.Globalization;
-
-namespace Volo.Abp.AspNetCore.Mvc.Localization
-{
- internal static class GlobalizationHelper
- {
- public static bool IsValidCultureCode(string cultureCode)
- {
- if (cultureCode.IsNullOrWhiteSpace())
- {
- return false;
- }
-
- try
- {
- CultureInfo.GetCultureInfo(cultureCode);
- return true;
- }
- catch (CultureNotFoundException)
- {
- return false;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/AbpExtraPropertiesDictionaryModelBinderProvider.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/AbpExtraPropertiesDictionaryModelBinderProvider.cs
new file mode 100644
index 0000000000..3ed1eda3a1
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/AbpExtraPropertiesDictionaryModelBinderProvider.cs
@@ -0,0 +1,48 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.ModelBinding;
+using Microsoft.AspNetCore.Mvc.ModelBinding.Binders;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Options;
+using Volo.Abp.Data;
+
+namespace Volo.Abp.AspNetCore.Mvc.ModelBinding
+{
+ public class AbpExtraPropertiesDictionaryModelBinderProvider : IModelBinderProvider
+ {
+ public IModelBinder GetBinder(ModelBinderProviderContext context)
+ {
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (context.Metadata.ModelType != typeof(Dictionary))
+ {
+ return null;
+ }
+
+ if (!context.Metadata.ContainerType.IsAssignableTo())
+ {
+ return null;
+ }
+
+ var binderType = typeof(DictionaryModelBinder);
+ var keyBinder = context.CreateBinder(context.MetadataProvider.GetMetadataForType(typeof(string)));
+ var valueBinder = new AbpExtraPropertyModelBinder(context.Metadata.ContainerType);
+ var loggerFactory = context.Services.GetRequiredService();
+ var mvcOptions = context.Services.GetRequiredService>().Value;
+
+ return (IModelBinder)Activator.CreateInstance(
+ binderType,
+ keyBinder,
+ valueBinder,
+ loggerFactory,
+ true /* allowValidatingTopLevelNodes */,
+ mvcOptions);
+ }
+ }
+}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/AbpExtraPropertyModelBinder.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/AbpExtraPropertyModelBinder.cs
new file mode 100644
index 0000000000..d3f570b1ce
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/AbpExtraPropertyModelBinder.cs
@@ -0,0 +1,65 @@
+using System;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Mvc.ModelBinding;
+using Volo.Abp.ObjectExtending;
+
+namespace Volo.Abp.AspNetCore.Mvc.ModelBinding
+{
+ public class AbpExtraPropertyModelBinder : IModelBinder
+ {
+ public Type ExtensibleObjectType { get; }
+
+ public AbpExtraPropertyModelBinder(Type extensibleObjectType)
+ {
+ ExtensibleObjectType = extensibleObjectType;
+ }
+
+ public virtual Task BindModelAsync(ModelBindingContext bindingContext)
+ {
+ var valueProviderResult = bindingContext.ValueProvider.GetValue(bindingContext.ModelName);
+ if (valueProviderResult == ValueProviderResult.None)
+ {
+ return Task.CompletedTask;
+ }
+
+ bindingContext.ModelState.SetModelValue(bindingContext.ModelName, valueProviderResult);
+
+ var model = ConvertStringToPropertyType(
+ bindingContext,
+ valueProviderResult.FirstValue
+ );
+
+ bindingContext.Result = ModelBindingResult.Success(model);
+
+ return Task.CompletedTask;
+ }
+
+ protected virtual object ConvertStringToPropertyType(ModelBindingContext bindingContext, string value)
+ {
+ if (bindingContext.ModelMetadata.ConvertEmptyStringToNull && string.IsNullOrWhiteSpace(value))
+ {
+ return null;
+ }
+
+ var extensionInfo = ObjectExtensionManager.Instance.GetOrNull(ExtensibleObjectType);
+ if (extensionInfo == null)
+ {
+ return value;
+ }
+
+ var propertyName = ExtraPropertyBindingHelper.ExtractExtraPropertyName(bindingContext.ModelName);
+ if (propertyName == null)
+ {
+ return value;
+ }
+
+ var propertyInfo = extensionInfo.GetPropertyOrNull(propertyName);
+ if (propertyInfo == null)
+ {
+ return value;
+ }
+
+ return Convert.ChangeType(value, propertyInfo.Type);
+ }
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/ExtraPropertyBindingHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/ExtraPropertyBindingHelper.cs
new file mode 100644
index 0000000000..0bd4c43173
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/ExtraPropertyBindingHelper.cs
@@ -0,0 +1,37 @@
+using System;
+
+namespace Volo.Abp.AspNetCore.Mvc.ModelBinding
+{
+ public static class ExtraPropertyBindingHelper
+ {
+ ///
+ /// is a string like "UserInfo.ExtraProperties[SocialSecurityNumber]"
+ /// This method returns "SocialSecurityNumber" for this example. */
+ ///
+ public static string ExtractExtraPropertyName(string expression)
+ {
+ var index = expression.IndexOf("ExtraProperties[", StringComparison.Ordinal);
+ if (index < 0)
+ {
+ return null;
+ }
+
+ return expression.Substring(index + 16, expression.Length - index - 17);
+ }
+
+ ///
+ /// is a string like "UserInfo.ExtraProperties[SocialSecurityNumber]"
+ /// This method returns "UserInfo" for this example.
+ ///
+ public static string ExtractContainerName(string expression)
+ {
+ var index = expression.IndexOf("ExtraProperties[", StringComparison.Ordinal);
+ if (index < 0)
+ {
+ return null;
+ }
+
+ return expression.Left(index).TrimEnd('.');
+ }
+ }
+}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/Metadata/AbpModelMetadataProvider.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/Metadata/AbpModelMetadataProvider.cs
index b77354aab2..94a08a0507 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/Metadata/AbpModelMetadataProvider.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/Metadata/AbpModelMetadataProvider.cs
@@ -1,11 +1,11 @@
using System.ComponentModel.DataAnnotations;
using System.Linq;
-using System.Reflection;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.ModelBinding.Metadata;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
+using Volo.Abp.AspNetCore.Mvc.Validation;
using Volo.Abp.DependencyInjection;
namespace Volo.Abp.AspNetCore.Mvc.ModelBinding.Metadata
@@ -14,14 +14,6 @@ namespace Volo.Abp.AspNetCore.Mvc.ModelBinding.Metadata
[ExposeServices(typeof(IModelMetadataProvider))]
public class AbpModelMetadataProvider : DefaultModelMetadataProvider
{
- private static readonly PropertyInfo ValidationAttributeErrorMessageStringProperty;
-
- static AbpModelMetadataProvider()
- {
- ValidationAttributeErrorMessageStringProperty = typeof(ValidationAttribute)
- .GetProperty("ErrorMessageString", BindingFlags.Instance | BindingFlags.NonPublic);
- }
-
public AbpModelMetadataProvider(ICompositeMetadataDetailsProvider detailsProvider)
: base(detailsProvider)
{
@@ -56,7 +48,7 @@ namespace Volo.Abp.AspNetCore.Mvc.ModelBinding.Metadata
{
if (validationAttribute.ErrorMessage == null)
{
- validationAttribute.ErrorMessage = ValidationAttributeErrorMessageStringProperty.GetValue(validationAttribute) as string;
+ ValidationAttributeHelper.SetDefaultErrorMessage(validationAttribute);
}
}
}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ProxyScripting/AbpServiceProxyScriptController.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ProxyScripting/AbpServiceProxyScriptController.cs
index 99cada9602..45df8d47ad 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ProxyScripting/AbpServiceProxyScriptController.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ProxyScripting/AbpServiceProxyScriptController.cs
@@ -10,6 +10,8 @@ namespace Volo.Abp.AspNetCore.Mvc.ProxyScripting
[Area("Abp")]
[Route("Abp/ServiceProxyScript")]
[DisableAuditing]
+ [RemoteService(false)]
+ [ApiExplorerSettings(IgnoreApi = true)]
public class AbpServiceProxyScriptController : AbpController
{
private readonly IProxyScriptManager _proxyScriptManager;
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Validation/ValidationAttributeHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Validation/ValidationAttributeHelper.cs
new file mode 100644
index 0000000000..955b83c48f
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Validation/ValidationAttributeHelper.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Reflection;
+using System.Text;
+
+namespace Volo.Abp.AspNetCore.Mvc.Validation
+{
+ public static class ValidationAttributeHelper
+ {
+ private static readonly PropertyInfo ValidationAttributeErrorMessageStringProperty = typeof(ValidationAttribute)
+ .GetProperty("ErrorMessageString", BindingFlags.Instance | BindingFlags.NonPublic);
+
+ public static void SetDefaultErrorMessage(ValidationAttribute validationAttribute)
+ {
+ validationAttribute.ErrorMessage =
+ ValidationAttributeErrorMessageStringProperty.GetValue(validationAttribute) as string;
+ }
+ }
+}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ViewFeatures/AbpValidationHtmlAttributeProvider.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ViewFeatures/AbpValidationHtmlAttributeProvider.cs
new file mode 100644
index 0000000000..84a3d05e25
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ViewFeatures/AbpValidationHtmlAttributeProvider.cs
@@ -0,0 +1,132 @@
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Reflection;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.DataAnnotations;
+using Microsoft.AspNetCore.Mvc.ModelBinding;
+using Microsoft.AspNetCore.Mvc.ModelBinding.Metadata;
+using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
+using Microsoft.AspNetCore.Mvc.Rendering;
+using Microsoft.AspNetCore.Mvc.ViewFeatures;
+using Microsoft.Extensions.Localization;
+using Microsoft.Extensions.Options;
+using Volo.Abp.AspNetCore.Mvc.ModelBinding;
+using Volo.Abp.AspNetCore.Mvc.Validation;
+using Volo.Abp.DependencyInjection;
+using Volo.Abp.Localization;
+using Volo.Abp.ObjectExtending;
+using Volo.Abp.Validation.Localization;
+
+namespace Volo.Abp.AspNetCore.Mvc.ViewFeatures
+{
+ [Dependency(ReplaceServices = true)]
+ [ExposeServices(typeof(ValidationHtmlAttributeProvider))]
+ public class AbpValidationHtmlAttributeProvider
+ : DefaultValidationHtmlAttributeProvider, ISingletonDependency
+ {
+ private readonly IModelMetadataProvider _metadataProvider;
+ private readonly IStringLocalizerFactory _stringLocalizerFactory;
+ private readonly IStringLocalizer _validationStringLocalizer;
+ private readonly IValidationAttributeAdapterProvider _validationAttributeAdapterProvider;
+
+ public AbpValidationHtmlAttributeProvider(
+ IOptions optionsAccessor,
+ IModelMetadataProvider metadataProvider,
+ ClientValidatorCache clientValidatorCache,
+ IValidationAttributeAdapterProvider validationAttributeAdapterProvider,
+ IStringLocalizerFactory stringLocalizerFactory,
+ IStringLocalizer validationStringLocalizer)
+ : base(
+ optionsAccessor,
+ metadataProvider,
+ clientValidatorCache)
+ {
+ _metadataProvider = metadataProvider;
+ _validationAttributeAdapterProvider = validationAttributeAdapterProvider;
+ _stringLocalizerFactory = stringLocalizerFactory;
+ _validationStringLocalizer = validationStringLocalizer;
+ }
+
+ public override void AddValidationAttributes(
+ ViewContext viewContext,
+ ModelExplorer modelExplorer,
+ IDictionary attributes)
+ {
+ base.AddValidationAttributes(viewContext, modelExplorer, attributes);
+ AddExtraPropertyValidationsAttributes(viewContext, modelExplorer, attributes);
+ }
+
+ protected virtual void AddExtraPropertyValidationsAttributes(ViewContext viewContext, ModelExplorer modelExplorer, IDictionary attributes)
+ {
+ var nameAttribute = attributes.GetOrDefault("name");
+ if (nameAttribute == null)
+ {
+ return;
+ }
+
+ var extraPropertyName = ExtraPropertyBindingHelper.ExtractExtraPropertyName(nameAttribute);
+ if (extraPropertyName == null)
+ {
+ return;
+ }
+
+ //TODO: containerName can be null on controller actions..?
+ var containerName = ExtraPropertyBindingHelper.ExtractContainerName(nameAttribute);
+ if (containerName == null)
+ {
+ return;
+ }
+
+ if (modelExplorer.Container?.ModelType == null)
+ {
+ return;
+ }
+
+ var extensibleObjectType = modelExplorer.Container.ModelType
+ .GetProperty(containerName, BindingFlags.Instance | BindingFlags.Public)
+ ?.PropertyType;
+ if (extensibleObjectType == null)
+ {
+ return;
+ }
+
+ var extensionPropertyInfo = ObjectExtensionManager.Instance.GetPropertyOrNull(
+ extensibleObjectType,
+ extraPropertyName
+ );
+
+ if (extensionPropertyInfo == null)
+ {
+ return;
+ }
+
+ if (modelExplorer.Metadata is DefaultModelMetadata metadata)
+ {
+ metadata.DisplayMetadata.DisplayName =
+ () => extensionPropertyInfo.GetLocalizedDisplayName(_stringLocalizerFactory);
+ }
+
+ foreach (var validationAttribute in extensionPropertyInfo.GetValidationAttributes())
+ {
+ var validationContext = new ClientModelValidationContext(
+ viewContext,
+ modelExplorer.Metadata,
+ _metadataProvider,
+ attributes
+ );
+
+ if (validationAttribute.ErrorMessage == null)
+ {
+ ValidationAttributeHelper.SetDefaultErrorMessage(validationAttribute);
+ }
+
+ var validationAttributeAdapter = _validationAttributeAdapterProvider.GetAttributeAdapter(
+ validationAttribute,
+ _validationStringLocalizer
+ );
+
+ validationAttributeAdapter?.AddValidation(validationContext);
+ }
+ }
+ }
+}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/ObjectExtending/ObjectExtendingPropertyInfoExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/ObjectExtending/ObjectExtendingPropertyInfoExtensions.cs
new file mode 100644
index 0000000000..9bb6c903a9
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/ObjectExtending/ObjectExtendingPropertyInfoExtensions.cs
@@ -0,0 +1,98 @@
+using System;
+using System.ComponentModel.DataAnnotations;
+using Microsoft.AspNetCore.Mvc;
+
+namespace Volo.Abp.ObjectExtending
+{
+ public static class ObjectExtensionPropertyInfoAspNetCoreMvcExtensions
+ {
+ public static string GetInputType(this ObjectExtensionPropertyInfo propertyInfo)
+ {
+ foreach (var attribute in propertyInfo.Attributes)
+ {
+ var inputTypeByAttribute = GetInputTypeFromAttributeOrNull(attribute);
+ if (inputTypeByAttribute != null)
+ {
+ return inputTypeByAttribute;
+ }
+ }
+
+ return GetInputTypeFromTypeOrNull(propertyInfo.Type)
+ ?? "text"; //default
+ }
+
+ private static string GetInputTypeFromAttributeOrNull(Attribute attribute)
+ {
+ if (attribute is EmailAddressAttribute)
+ {
+ return "email";
+ }
+
+ if (attribute is UrlAttribute)
+ {
+ return "url";
+ }
+
+ if (attribute is HiddenInputAttribute)
+ {
+ return "hidden";
+ }
+
+ if (attribute is PhoneAttribute)
+ {
+ return "tel";
+ }
+
+ if (attribute is DataTypeAttribute dataTypeAttribute)
+ {
+ switch (dataTypeAttribute.DataType)
+ {
+ case DataType.Password:
+ return "password";
+ case DataType.Date:
+ return "date";
+ case DataType.Time:
+ return "time";
+ case DataType.EmailAddress:
+ return "email";
+ case DataType.Url:
+ return "url";
+ case DataType.PhoneNumber:
+ return "tel";
+ case DataType.DateTime:
+ return "datetime-local";
+ }
+ }
+
+ return null;
+ }
+
+ private static string GetInputTypeFromTypeOrNull(Type type)
+ {
+ if (type == typeof(bool))
+ {
+ return "checkbox";
+ }
+
+ if (type == typeof(DateTime))
+ {
+ return "datetime-local";
+ }
+
+ if (type == typeof(int) ||
+ type == typeof(long) ||
+ type == typeof(byte) ||
+ type == typeof(sbyte) ||
+ type == typeof(short) ||
+ type == typeof(ushort) ||
+ type == typeof(uint) ||
+ type == typeof(long) ||
+ type == typeof(ulong))
+ {
+ return "number";
+ }
+
+ return null;
+ }
+ }
+}
diff --git a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/VirtualFileSystem/WebContentFileProvider.cs b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/VirtualFileSystem/WebContentFileProvider.cs
index 1b71dad8cb..4fab6d0001 100644
--- a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/VirtualFileSystem/WebContentFileProvider.cs
+++ b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/VirtualFileSystem/WebContentFileProvider.cs
@@ -1,8 +1,10 @@
using System;
+using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.FileProviders;
+using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using Microsoft.Extensions.Primitives;
using Volo.Abp.DependencyInjection;
@@ -91,9 +93,27 @@ namespace Volo.Abp.AspNetCore.VirtualFileSystem
protected virtual IFileProvider CreateFileProvider()
{
- return new CompositeFileProvider(
+ var fileProviders = new List()
+ {
new PhysicalFileProvider(_hostingEnvironment.ContentRootPath),
_virtualFileProvider
+ };
+
+ if (_hostingEnvironment.IsDevelopment() &&
+ _hostingEnvironment.WebRootFileProvider is CompositeFileProvider compositeFileProvider)
+ {
+ var staticWebAssetsFileProvider = compositeFileProvider
+ .FileProviders
+ .FirstOrDefault(f => f.GetType().Name.Equals("StaticWebAssetsFileProvider"));
+
+ if (staticWebAssetsFileProvider != null)
+ {
+ fileProviders.Add(staticWebAssetsFileProvider);
+ }
+ }
+
+ return new CompositeFileProvider(
+ fileProviders
);
}
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GenerateProxyCommand.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GenerateProxyCommand.cs
index accf5eddb9..5c732f6873 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GenerateProxyCommand.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GenerateProxyCommand.cs
@@ -20,6 +20,7 @@ namespace Volo.Abp.Cli.Commands
{
public static Dictionary> propertyList = new Dictionary>();
public ILogger Logger { get; set; }
+ public static string outputPrefix = "src/app";
protected TemplateProjectBuilder TemplateProjectBuilder { get; }
@@ -100,14 +101,22 @@ namespace Volo.Abp.Cli.Commands
Logger.LogInformation($"{rootPath} directory is creating");
- Directory.CreateDirectory($"src/app/{rootPath}/shared/models");
- Directory.CreateDirectory($"src/app/{rootPath}/shared/services");
+ if (rootPath == "app")
+ {
+ outputPrefix = "src";
+ }
+ else
+ {
+ outputPrefix = "src/app";
+ }
- var serviceIndexList = new List();
- var modelIndexList = new List();
+ Directory.CreateDirectory($"{outputPrefix}/{rootPath}");
foreach (var controller in moduleValue.Root.ToList().Select(item => item.First))
{
+ var serviceIndexList = new List();
+ var modelIndexList = new List();
+
var serviceFileText = new StringBuilder();
serviceFileText.AppendLine("[firstTypeList]");
@@ -128,6 +137,12 @@ namespace Volo.Abp.Cli.Commands
var controllerName = (string)controller["controllerName"];
var controllerServiceName = controllerName.PascalToKebabCase() + ".service.ts";
+ var controllerPathName = controllerName.ToLower().Replace("controller", "");
+ controllerPathName = (controllerPathName.StartsWith(rootPath)) ? controllerPathName.Substring(rootPath.Length) : controllerPathName;
+
+ Directory.CreateDirectory($"{outputPrefix}/{rootPath}/{controllerPathName}/models");
+ Directory.CreateDirectory($"{outputPrefix}/{rootPath}/{controllerPathName}/services");
+
foreach (var actionItem in controller["actions"])
{
var action = actionItem.First;
@@ -157,7 +172,7 @@ namespace Volo.Abp.Cli.Commands
var isOptional = (bool)parameter["isOptional"];
var defaultValue = (string)parameter["defaultValue"];
- var modelIndex = CreateType(data, (string)parameter["type"], rootPath, modelIndexList);
+ var modelIndex = CreateType(data, (string)parameter["type"], rootPath, modelIndexList, controllerPathName);
if (!string.IsNullOrWhiteSpace(modelIndex))
{
@@ -194,7 +209,7 @@ namespace Volo.Abp.Cli.Commands
parameterModel = AddParameter(name, typeSimple, isOptional, defaultValue, bindingSourceId, parameterModel);
}
- modelIndex = CreateType(data, (string)parameterOnMethod["type"], rootPath, modelIndexList);
+ modelIndex = CreateType(data, (string)parameterOnMethod["type"], rootPath, modelIndexList, controllerPathName);
if (!string.IsNullOrWhiteSpace(modelIndex))
{
@@ -225,7 +240,7 @@ namespace Volo.Abp.Cli.Commands
foreach (var parameterItem in parameterModel.OrderBy(p => p.DisplayOrder))
{
var parameterItemModelName = parameterItem.Type.PascalToKebabCase() + ".ts";
- var parameterItemModelPath = $"src/app/{rootPath}/shared/models/{parameterItemModelName}";
+ var parameterItemModelPath = $"{outputPrefix}/{rootPath}/{controllerPathName}/models/{parameterItemModelName}";
if (parameterItem.BindingSourceId == "body" && !File.Exists(parameterItemModelPath))
{
parameterItem.Type = "any";
@@ -262,7 +277,7 @@ namespace Volo.Abp.Cli.Commands
var secondType = secondTypeArray[secondTypeArray.Length - 1].TrimEnd('>');
var secondTypeModelName = secondType.PascalToKebabCase() + ".ts";
- var secondTypeModelPath = $"src/app/{rootPath}/shared/models/{secondTypeModelName}";
+ var secondTypeModelPath = $"{outputPrefix}/{rootPath}/{controllerPathName}/models/{secondTypeModelName}";
if (firstType == "List" && !File.Exists(secondTypeModelPath))
{
secondType = "any";
@@ -306,7 +321,7 @@ namespace Volo.Abp.Cli.Commands
}
}
- var modelIndex = CreateType(data, returnValueType, rootPath, modelIndexList);
+ var modelIndex = CreateType(data, returnValueType, rootPath, modelIndexList, controllerPathName);
if (!string.IsNullOrWhiteSpace(modelIndex))
{
@@ -359,26 +374,31 @@ namespace Volo.Abp.Cli.Commands
serviceFileText.AppendLine("}");
serviceFileText.Replace("[controllerName]", controllerName);
- File.WriteAllText($"src/app/{rootPath}/shared/services/{controllerServiceName}", serviceFileText.ToString());
- }
+ File.WriteAllText($"{outputPrefix}/{rootPath}/{controllerPathName}/services/{controllerServiceName}", serviceFileText.ToString());
- var serviceIndexFileText = new StringBuilder();
- foreach (var serviceIndexItem in serviceIndexList.Distinct())
- {
- serviceIndexFileText.AppendLine($"export * from './{serviceIndexItem}';");
- }
- File.WriteAllText($"src/app/{rootPath}/shared/services/index.ts", serviceIndexFileText.ToString());
+ var serviceIndexFileText = new StringBuilder();
- var modelIndexFileText = new StringBuilder();
+ foreach (var serviceIndexItem in serviceIndexList.Distinct())
+ {
+ serviceIndexFileText.AppendLine($"export * from './{serviceIndexItem}';");
+ }
- foreach (var modelIndexItem in modelIndexList.Distinct())
- {
- modelIndexFileText.AppendLine($"export * from './{modelIndexItem}';");
- }
+ File.WriteAllText($"{outputPrefix}/{rootPath}/{controllerPathName}/services/index.ts", serviceIndexFileText.ToString());
+
+ if (modelIndexList.Count > 0)
+ {
+ var modelIndexFileText = new StringBuilder();
+
+ foreach (var modelIndexItem in modelIndexList.Distinct())
+ {
+ modelIndexFileText.AppendLine($"export * from './{modelIndexItem}';");
+ }
- File.WriteAllText($"src/app/{rootPath}/shared/models/index.ts", modelIndexFileText.ToString());
+ File.WriteAllText($"{outputPrefix}/{rootPath}/{controllerPathName}/models/index.ts", modelIndexFileText.ToString());
+ }
+ }
}
Logger.LogInformation("Completed!");
@@ -415,7 +435,7 @@ namespace Volo.Abp.Cli.Commands
return moduleList;
}
- private static string CreateType(JObject data, string returnValueType, string rootPath, List modelIndexList)
+ private static string CreateType(JObject data, string returnValueType, string rootPath, List modelIndexList, string controllerPathName)
{
var type = data["types"][returnValueType];
@@ -425,30 +445,45 @@ namespace Volo.Abp.Cli.Commands
}
if (returnValueType.StartsWith("Volo.Abp.Application.Dtos")
- || returnValueType.StartsWith("System.Collections")
- || returnValueType == "System.String"
- || returnValueType == "System.Void"
- || returnValueType.Contains("System.Net.HttpStatusCode?")
- || returnValueType.Contains("IActionResult")
- || returnValueType.Contains("ActionResult")
- || returnValueType.Contains("IStringValueType")
- || returnValueType.Contains("IValueValidator")
- )
+ || returnValueType.StartsWith("System.Collections")
+ || returnValueType == "System.String"
+ || returnValueType == "System.Void"
+ || returnValueType.Contains("System.Net.HttpStatusCode?")
+ || returnValueType.Contains("IActionResult")
+ || returnValueType.Contains("ActionResult")
+ || returnValueType.Contains("IStringValueType")
+ || returnValueType.Contains("IValueValidator")
+ )
{
- return null;
+ if (returnValueType.Contains("<"))
+ {
+ returnValueType = returnValueType.Split('<')[1].Split('>')[0];
+ if (returnValueType.StartsWith("Volo.Abp.Application.Dtos")
+ || returnValueType.StartsWith("System.Collections")
+ || returnValueType == "System.String"
+ || returnValueType == "System.Void"
+ || returnValueType.Contains("System.Net.HttpStatusCode?")
+ || returnValueType.Contains("IActionResult")
+ || returnValueType.Contains("ActionResult")
+ || returnValueType.Contains("IStringValueType")
+ || returnValueType.Contains("IValueValidator")
+ )
+ {
+ return null;
+ }
+ }
+ else
+ {
+ return null;
+ }
}
var typeNameSplit = returnValueType.Split(".");
var typeName = typeNameSplit[typeNameSplit.Length - 1];
- if (typeName.Contains("HttpStatusCode"))
- {
-
- }
-
var typeModelName = typeName.Replace("<", "").Replace(">", "").Replace("?", "").PascalToKebabCase() + ".ts";
- var path = $"src/app/{rootPath}/shared/models/{typeModelName}";
+ var path = $"{outputPrefix}/{rootPath}/{controllerPathName}/models/{typeModelName}";
var modelFileText = new StringBuilder();
@@ -481,7 +516,7 @@ namespace Volo.Abp.Cli.Commands
modelFileText.AppendLine($"import {{ {baseTypeName} }} from '{baseTypeKebabCase}';");
extends = "extends " + (!string.IsNullOrWhiteSpace(customBaseTypeName) ? customBaseTypeName : baseTypeName);
- var modelIndex = CreateType(data, baseType, rootPath, modelIndexList);
+ var modelIndex = CreateType(data, baseType, rootPath, modelIndexList, controllerPathName);
if (!string.IsNullOrWhiteSpace(modelIndex))
{
modelIndexList.Add(modelIndex);
@@ -514,7 +549,7 @@ namespace Volo.Abp.Cli.Commands
propertyName = (char.ToLower(propertyName[0]) + propertyName.Substring(1));
var typeSimple = (string)property["typeSimple"];
- var modelIndex = CreateType(data, (string)property["type"], rootPath, modelIndexList);
+ var modelIndex = CreateType(data, (string)property["type"], rootPath, modelIndexList, controllerPathName);
if (typeSimple.IndexOf("[") > -1 && typeSimple.IndexOf("]") > -1)
{
@@ -547,7 +582,7 @@ namespace Volo.Abp.Cli.Commands
)
{
var typeSimpleModelName = typeSimple.PascalToKebabCase() + ".ts";
- var modelPath = $"src/app/{rootPath}/shared/models/{typeSimpleModelName}";
+ var modelPath = $"{outputPrefix}/{rootPath}/{controllerPathName}/models/{typeSimpleModelName}";
if (!File.Exists(modelPath))
{
typeSimple = "any" + (typeSimple.Contains("[]") ? "[]" : "");
@@ -561,10 +596,18 @@ namespace Volo.Abp.Cli.Commands
if (!string.IsNullOrWhiteSpace(modelIndex))
{
+ var from = "../models";
var propertyTypeSplit = ((string)property["type"]).Split(".");
var propertyType = propertyTypeSplit[propertyTypeSplit.Length - 1];
+
+ var propertyTypeKebabCase = propertyType.PascalToKebabCase();
+ if (File.Exists($"{outputPrefix}/{rootPath}/{controllerPathName}/models/{propertyTypeKebabCase}.ts"))
+ {
+ from = "./" + propertyTypeKebabCase;
+ }
+
modelFileText.Insert(0, "");
- modelFileText.Insert(0, $"import {{ {propertyType} }} from '../models';");
+ modelFileText.Insert(0, $"import {{ {propertyType} }} from '{from}';");
modelFileText.Insert(0, "");
modelIndexList.Add(modelIndex);
}
@@ -608,7 +651,7 @@ namespace Volo.Abp.Cli.Commands
modelFileText.AppendLine("}");
}
- File.WriteAllText($"src/app/{rootPath}/shared/models/{typeModelName}", modelFileText.ToString());
+ File.WriteAllText($"{outputPrefix}/{rootPath}/{controllerPathName}/models/{typeModelName}", modelFileText.ToString());
return typeModelName.Replace(".ts", "");
}
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/Microsoft/Extensions/Localization/AbpStringLocalizerFactoryExtensions.cs b/framework/src/Volo.Abp.Core/Microsoft/Extensions/Localization/AbpStringLocalizerFactoryExtensions.cs
index 34931bfc95..3995bf4440 100644
--- a/framework/src/Volo.Abp.Core/Microsoft/Extensions/Localization/AbpStringLocalizerFactoryExtensions.cs
+++ b/framework/src/Volo.Abp.Core/Microsoft/Extensions/Localization/AbpStringLocalizerFactoryExtensions.cs
@@ -1,6 +1,6 @@
namespace Microsoft.Extensions.Localization
{
- public static class AbpStringLocalizerFactoryExtensions
+ public static class AbpCoreStringLocalizerFactoryExtensions
{
public static IStringLocalizer Create(this IStringLocalizerFactory localizerFactory)
{
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/DefaultConventionalRegistrar.cs b/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/DefaultConventionalRegistrar.cs
index 15361ece62..5f4d64f512 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/DefaultConventionalRegistrar.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/DefaultConventionalRegistrar.cs
@@ -1,4 +1,6 @@
using System;
+using System.Collections.Generic;
+using System.Linq;
using System.Reflection;
using JetBrains.Annotations;
using Microsoft.Extensions.DependencyInjection;
@@ -24,13 +26,18 @@ namespace Volo.Abp.DependencyInjection
return;
}
- var serviceTypes = ExposedServiceExplorer.GetExposedServices(type);
+ var exposedServiceTypes = ExposedServiceExplorer.GetExposedServices(type);
- TriggerServiceExposing(services, type, serviceTypes);
+ TriggerServiceExposing(services, type, exposedServiceTypes);
- foreach (var serviceType in serviceTypes)
+ foreach (var exposedServiceType in exposedServiceTypes)
{
- var serviceDescriptor = ServiceDescriptor.Describe(serviceType, type, lifeTime.Value);
+ var serviceDescriptor = CreateServiceDescriptor(
+ type,
+ exposedServiceType,
+ exposedServiceTypes,
+ lifeTime.Value
+ );
if (dependencyAttribute?.ReplaceServices == true)
{
@@ -46,7 +53,63 @@ namespace Volo.Abp.DependencyInjection
}
}
}
-
+
+ protected virtual ServiceDescriptor CreateServiceDescriptor(
+ Type implementationType,
+ Type exposingServiceType,
+ List allExposingServiceTypes,
+ ServiceLifetime lifeTime)
+ {
+ if (lifeTime.IsIn(ServiceLifetime.Singleton, ServiceLifetime.Scoped))
+ {
+ var redirectedType = GetRedirectedTypeOrNull(
+ implementationType,
+ exposingServiceType,
+ allExposingServiceTypes
+ );
+
+ if (redirectedType != null)
+ {
+ return ServiceDescriptor.Describe(
+ exposingServiceType,
+ provider => provider.GetService(redirectedType),
+ lifeTime
+ );
+ }
+ }
+
+ return ServiceDescriptor.Describe(
+ exposingServiceType,
+ implementationType,
+ lifeTime
+ );
+ }
+
+ protected virtual Type GetRedirectedTypeOrNull(
+ Type implementationType,
+ Type exposingServiceType,
+ List allExposingServiceTypes)
+ {
+ if (allExposingServiceTypes.Count < 2)
+ {
+ return null;
+ }
+
+ if (exposingServiceType == implementationType)
+ {
+ return null;
+ }
+
+ if (allExposingServiceTypes.Contains(implementationType))
+ {
+ return implementationType;
+ }
+
+ return allExposingServiceTypes.FirstOrDefault(
+ t => t != exposingServiceType && exposingServiceType.IsAssignableFrom(t)
+ );
+ }
+
protected virtual DependencyAttribute GetDependencyAttributeOrNull(Type type)
{
return type.GetCustomAttribute(true);
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..f27f52089a 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,30 @@ namespace Volo.Abp.Localization
CultureInfo.CurrentUICulture = currentUiCulture;
});
}
+
+ public static bool IsValidCultureCode(string cultureCode)
+ {
+ if (cultureCode.IsNullOrWhiteSpace())
+ {
+ return false;
+ }
+
+ try
+ {
+ CultureInfo.GetCultureInfo(cultureCode);
+ return true;
+ }
+ catch (CultureNotFoundException)
+ {
+ return false;
+ }
+ }
+
+ public static string GetBaseCultureName(string cultureName)
+ {
+ return cultureName.Contains("-")
+ ? cultureName.Left(cultureName.IndexOf("-", StringComparison.Ordinal))
+ : cultureName;
+ }
}
}
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/TypeHelper.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/TypeHelper.cs
index 5f66f4788e..11f43f852e 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/TypeHelper.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/TypeHelper.cs
@@ -3,6 +3,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
+using JetBrains.Annotations;
namespace Volo.Abp.Reflection
{
@@ -131,5 +132,137 @@ namespace Volo.Abp.Reflection
type == typeof(TimeSpan) ||
type == typeof(Guid);
}
+
+ public static T GetDefaultValue()
+ {
+ return default;
+ }
+
+ public static object GetDefaultValue(Type type)
+ {
+ if (type.IsValueType)
+ {
+ return Activator.CreateInstance(type);
+ }
+
+ return null;
+ }
+
+ public static string GetFullNameHandlingNullableAndGenerics([NotNull] Type type)
+ {
+ Check.NotNull(type, nameof(type));
+
+ if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>))
+ {
+ return type.GenericTypeArguments[0].FullName + "?";
+ }
+
+ if (type.IsGenericType)
+ {
+ var genericType = type.GetGenericTypeDefinition();
+ return $"{genericType.FullName.Left(genericType.FullName.IndexOf('`'))}<{type.GenericTypeArguments.Select(GetFullNameHandlingNullableAndGenerics).JoinAsString(",")}>";
+ }
+
+ return type.FullName;
+ }
+
+ public static string GetSimplifiedName([NotNull] Type type)
+ {
+ Check.NotNull(type, nameof(type));
+
+ if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>))
+ {
+ return GetSimplifiedName(type.GenericTypeArguments[0]) + "?";
+ }
+
+ if (type.IsGenericType)
+ {
+ var genericType = type.GetGenericTypeDefinition();
+ return $"{genericType.FullName.Left(genericType.FullName.IndexOf('`'))}<{type.GenericTypeArguments.Select(GetSimplifiedName).JoinAsString(",")}>";
+ }
+
+ if (type == typeof(string))
+ {
+ return "string";
+ }
+ else if (type == typeof(int))
+ {
+ return "number";
+ }
+ else if (type == typeof(long))
+ {
+ return "number";
+ }
+ else if (type == typeof(bool))
+ {
+ return "boolean";
+ }
+ else if (type == typeof(char))
+ {
+ return "string";
+ }
+ else if (type == typeof(double))
+ {
+ return "number";
+ }
+ else if (type == typeof(float))
+ {
+ return "number";
+ }
+ else if (type == typeof(decimal))
+ {
+ return "number";
+ }
+ else if (type == typeof(DateTime))
+ {
+ return "string";
+ }
+ else if (type == typeof(DateTimeOffset))
+ {
+ return "string";
+ }
+ else if (type == typeof(TimeSpan))
+ {
+ return "string";
+ }
+ else if (type == typeof(Guid))
+ {
+ return "string";
+ }
+ else if (type == typeof(byte))
+ {
+ return "number";
+ }
+ else if (type == typeof(sbyte))
+ {
+ return "number";
+ }
+ else if (type == typeof(short))
+ {
+ return "number";
+ }
+ else if (type == typeof(ushort))
+ {
+ return "number";
+ }
+ else if (type == typeof(uint))
+ {
+ return "number";
+ }
+ else if (type == typeof(ulong))
+ {
+ return "number";
+ }
+ else if (type == typeof(IntPtr))
+ {
+ return "number";
+ }
+ else if (type == typeof(UIntPtr))
+ {
+ return "number";
+ }
+
+ return type.FullName;
+ }
}
}
diff --git a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Localization/Resources/AbpDdd/de.json b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Localization/Resources/AbpDdd/de.json
new file mode 100644
index 0000000000..b96b58c2b3
--- /dev/null
+++ b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Localization/Resources/AbpDdd/de.json
@@ -0,0 +1,6 @@
+{
+ "culture": "de",
+ "texts": {
+ "MaxResultCountExceededExceptionMessage": "{0} kann nicht mehr als {1} sein! Erhöhen Sie {2}.{3} auf der Serverseite, um mehr Ergebnisse zu ermöglichen."
+ }
+}
diff --git a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Localization/Resources/AbpDdd/nl.json b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Localization/Resources/AbpDdd/nl.json
new file mode 100644
index 0000000000..cc4412cffc
--- /dev/null
+++ b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Localization/Resources/AbpDdd/nl.json
@@ -0,0 +1,6 @@
+{
+ "culture": "nl",
+ "texts": {
+ "MaxResultCountExceededExceptionMessage": "{0} kan niet meer dan {1} zijn! Vergroot {2}.{3} op de server om een groter resultaat toe te staan."
+ }
+}
diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/AggregateRoot.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/AggregateRoot.cs
index be02f3d398..b0c20131ef 100644
--- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/AggregateRoot.cs
+++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/AggregateRoot.cs
@@ -25,8 +25,9 @@ namespace Volo.Abp.Domain.Entities
protected AggregateRoot()
{
- ExtraProperties = new Dictionary();
ConcurrencyStamp = Guid.NewGuid().ToString("N");
+ ExtraProperties = new Dictionary();
+ this.SetDefaultsForExtraProperties();
}
protected virtual void AddLocalEvent(object eventData)
@@ -85,15 +86,17 @@ namespace Volo.Abp.Domain.Entities
protected AggregateRoot()
{
- ExtraProperties = new Dictionary();
ConcurrencyStamp = Guid.NewGuid().ToString("N");
+ ExtraProperties = new Dictionary();
+ this.SetDefaultsForExtraProperties();
}
protected AggregateRoot(TKey id)
: base(id)
{
- ExtraProperties = new Dictionary();
ConcurrencyStamp = Guid.NewGuid().ToString("N");
+ ExtraProperties = new Dictionary();
+ this.SetDefaultsForExtraProperties();
}
protected virtual void AddLocalEvent(object eventData)
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/Localization/de.json b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Localization/de.json
new file mode 100644
index 0000000000..8d6ae8c9ff
--- /dev/null
+++ b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Localization/de.json
@@ -0,0 +1,23 @@
+{
+ "culture": "de",
+ "texts": {
+ "DisplayName:Abp.Mailing.DefaultFromAddress": "Standard-Absenderadresse",
+ "DisplayName:Abp.Mailing.DefaultFromDisplayName": "Standard-Absendername",
+ "DisplayName:Abp.Mailing.Smtp.Host": "Host",
+ "DisplayName:Abp.Mailing.Smtp.Port": "Port",
+ "DisplayName:Abp.Mailing.Smtp.UserName": "Benutzername",
+ "DisplayName:Abp.Mailing.Smtp.Password": "Passwort",
+ "DisplayName:Abp.Mailing.Smtp.Domain": "Domain",
+ "DisplayName:Abp.Mailing.Smtp.EnableSsl": "SSL aktivieren",
+ "DisplayName:Abp.Mailing.Smtp.UseDefaultCredentials": "Standard-Anmeldeinformationen verwenden",
+ "Description:Abp.Mailing.DefaultFromAddress": "Die Standard-Absenderadresse",
+ "Description:Abp.Mailing.DefaultFromDisplayName": "Der Standard-Absendername",
+ "Description:Abp.Mailing.Smtp.Host": "Der Name oder die IP-Adresse des für SMTP-Transaktionen verwendeten Hosts.",
+ "Description:Abp.Mailing.Smtp.Port": "Der für SMTP-Transaktionen verwendete Port.",
+ "Description:Abp.Mailing.Smtp.UserName": "Benutzername, der mit den Anmeldedaten verknüpft ist.",
+ "Description:Abp.Mailing.Smtp.Password": "Das Passwort für den Benutzernamen, der mit den Anmeldeinformationen verknüpft ist.",
+ "Description:Abp.Mailing.Smtp.Domain": "Die Domäne oder der Computername, der die Anmeldeinformationen verifiziert.",
+ "Description:Abp.Mailing.Smtp.EnableSsl": "Bestimmt, ob der SmptClient Secure Sockets Layer (SSL) zur Verschlüsselung der Verbindung verwendet.",
+ "Description:Abp.Mailing.Smtp.UseDefaultCredentials": "Bestimmt, ob die DefaultCredentials mit Anfragen gesendet werden."
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Localization/en.json b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Localization/en.json
index 6fa4e626ff..4444e1bfd6 100644
--- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Localization/en.json
+++ b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Localization/en.json
@@ -18,6 +18,8 @@
"Description:Abp.Mailing.Smtp.Password": "The password for the user name associated with the credentials.",
"Description:Abp.Mailing.Smtp.Domain": "The domain or computer name that verifies the credentials.",
"Description:Abp.Mailing.Smtp.EnableSsl": "Whether the SmtpClient uses Secure Sockets Layer (SSL) to encrypt the connection.",
- "Description:Abp.Mailing.Smtp.UseDefaultCredentials": "Whether the DefaultCredentials are sent with requests."
+ "Description:Abp.Mailing.Smtp.UseDefaultCredentials": "Whether the DefaultCredentials are sent with requests.",
+ "TextTemplate:StandardEmailTemplates.Layout": "Default email layout template",
+ "TextTemplate:StandardEmailTemplates.Message": "Simple message template for emails"
}
}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Localization/nl.json b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Localization/nl.json
new file mode 100644
index 0000000000..923671e885
--- /dev/null
+++ b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Localization/nl.json
@@ -0,0 +1,23 @@
+{
+ "culture": "nl",
+ "texts": {
+ "DisplayName:Abp.Mailing.DefaultFromAddress": "Standard vanaf adres",
+ "DisplayName:Abp.Mailing.DefaultFromDisplayName": "Standaard vanaf weergave naam",
+ "DisplayName:Abp.Mailing.Smtp.Host": "Host",
+ "DisplayName:Abp.Mailing.Smtp.Port": "Poort",
+ "DisplayName:Abp.Mailing.Smtp.UserName": "Gebruiker naam",
+ "DisplayName:Abp.Mailing.Smtp.Password": "wachtwoord",
+ "DisplayName:Abp.Mailing.Smtp.Domain": "Domein",
+ "DisplayName:Abp.Mailing.Smtp.EnableSsl": "SSL toestaan",
+ "DisplayName:Abp.Mailing.Smtp.UseDefaultCredentials": "Gebruik standaard inloggegevens",
+ "Description:Abp.Mailing.DefaultFromAddress": "Standard vanaf adres",
+ "Description:Abp.Mailing.DefaultFromDisplayName": "Standaard vanaf weergave naam",
+ "Description:Abp.Mailing.Smtp.Host": "De naam of het IP-adres van de host die wordt gebruikt voor SMTP-transacties.",
+ "Description:Abp.Mailing.Smtp.Port": "De poort die wordt gebruikt voor SMTP-transacties.",
+ "Description:Abp.Mailing.Smtp.UserName": "Gebruikersnaam gekoppeld aan de inloggegevens.",
+ "Description:Abp.Mailing.Smtp.Password": "Het wachtwoord voor de gebruikersnaam die bij de inloggegevens hoort.",
+ "Description:Abp.Mailing.Smtp.Domain": "Het domein of de computernaam die de inloggegevens verifieert.",
+ "Description:Abp.Mailing.Smtp.EnableSsl": "Of de SmtpClient Secure Sockets Layer (SSL) gebruikt om de verbinding te versleutelen.",
+ "Description:Abp.Mailing.Smtp.UseDefaultCredentials": "Of de standaard inloggegevens worden verzonden met verzoeken."
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Localization/tr.json b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Localization/tr.json
new file mode 100644
index 0000000000..242920c8d9
--- /dev/null
+++ b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Localization/tr.json
@@ -0,0 +1,25 @@
+{
+ "culture": "tr",
+ "texts": {
+ "DisplayName:Abp.Mailing.DefaultFromAddress": "Varsayılan gönderici adresi",
+ "DisplayName:Abp.Mailing.DefaultFromDisplayName": "Varsayılan gönderici adı",
+ "DisplayName:Abp.Mailing.Smtp.Host": "Sunucu",
+ "DisplayName:Abp.Mailing.Smtp.Port": "Port",
+ "DisplayName:Abp.Mailing.Smtp.UserName": "Kullanıcı adı",
+ "DisplayName:Abp.Mailing.Smtp.Password": "Şifre",
+ "DisplayName:Abp.Mailing.Smtp.Domain": "Domain",
+ "DisplayName:Abp.Mailing.Smtp.EnableSsl": "SSL aktif",
+ "DisplayName:Abp.Mailing.Smtp.UseDefaultCredentials": "Varsayılan kimlik kullan",
+ "Description:Abp.Mailing.DefaultFromAddress": "Varsayılan gönderici adresi",
+ "Description:Abp.Mailing.DefaultFromDisplayName": "Varsayılan gönderici adı",
+ "Description:Abp.Mailing.Smtp.Host": "SMTP üzerinden e-posta göndermek için kullanılacak sunucunun IP adresi ya da adı.",
+ "Description:Abp.Mailing.Smtp.Port": "Sunucunun SMTP portu.",
+ "Description:Abp.Mailing.Smtp.UserName": "Varsayılan kimlik kullanılmaması durumunda kullanılacak kullanıcı adı.",
+ "Description:Abp.Mailing.Smtp.Password": "Varsayılan kimlik kullanılmaması durumunda kullanılacak şifre.",
+ "Description:Abp.Mailing.Smtp.Domain": "Kimlik bilgilerinin doğrulanacağı sunucu/domain.",
+ "Description:Abp.Mailing.Smtp.EnableSsl": "Email gönderiminde SSL kullanılıp kullanılmayacağı.",
+ "Description:Abp.Mailing.Smtp.UseDefaultCredentials": "Varsayılan kimlik bilgilerinin kullanılıp kullanılmayacağı.",
+ "TextTemplate:StandardEmailTemplates.Layout": "Varsayılan e-posta layout şablonu",
+ "TextTemplate:StandardEmailTemplates.Message": "Basit bir mesaj göndermek için e-posta şablonu"
+ }
+}
\ No newline at end of file
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
deleted file mode 100644
index c15012f0bf..0000000000
--- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/DefaultEmailTemplateProvider.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using Volo.Abp.Emailing.Templates.VirtualFiles;
-
-namespace Volo.Abp.Emailing.Templates
-{
- public class DefaultEmailTemplateProvider : EmailTemplateDefinitionProvider
- {
- public override void Define(IEmailTemplateDefinitionContext context)
- {
- context.Add(new EmailTemplateDefinition(StandardEmailTemplates.DefaultLayout, defaultCultureName: "en", isLayout: true, layout: null)
- .AddTemplateVirtualFiles("/Volo/Abp/Emailing/Templates/DefaultEmailTemplates/Layout"));
-
- context.Add(new EmailTemplateDefinition(StandardEmailTemplates.SimpleMessage, defaultCultureName: "en")
- .AddTemplateVirtualFiles("/Volo/Abp/Emailing/Templates/DefaultEmailTemplates/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.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.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.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.tpl b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/Message.tpl
new file mode 100644
index 0000000000..349de66b36
--- /dev/null
+++ b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/Message.tpl
@@ -0,0 +1 @@
+{{model.message}}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/StandardEmailTemplateDefinitionProvider.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/StandardEmailTemplateDefinitionProvider.cs
new file mode 100644
index 0000000000..8c20d8dd78
--- /dev/null
+++ b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/StandardEmailTemplateDefinitionProvider.cs
@@ -0,0 +1,28 @@
+using Volo.Abp.Emailing.Localization;
+using Volo.Abp.Localization;
+using Volo.Abp.TextTemplating;
+
+namespace Volo.Abp.Emailing.Templates
+{
+ public class StandardEmailTemplateDefinitionProvider : TemplateDefinitionProvider
+ {
+ public override void Define(ITemplateDefinitionContext context)
+ {
+ context.Add(
+ new TemplateDefinition(
+ StandardEmailTemplates.Layout,
+ displayName: LocalizableString.Create("TextTemplate:StandardEmailTemplates.Layout"),
+ isLayout: true
+ ).WithVirtualFilePath("/Volo/Abp/Emailing/Templates/Layout.tpl", true)
+ );
+
+ context.Add(
+ new TemplateDefinition(
+ StandardEmailTemplates.Message,
+ displayName: LocalizableString.Create