@ -0,0 +1,38 @@ |
|||||
|
# Configuration for Lock Threads - https://github.com/dessant/lock-threads-app |
||||
|
|
||||
|
# Number of days of inactivity before a closed issue or pull request is locked |
||||
|
daysUntilLock: 30 |
||||
|
|
||||
|
# Skip issues and pull requests created before a given timestamp. Timestamp must |
||||
|
# follow ISO 8601 (`YYYY-MM-DD`). Set to `false` to disable |
||||
|
skipCreatedBefore: false |
||||
|
|
||||
|
# Issues and pull requests with these labels will be ignored. Set to `[]` to disable |
||||
|
exemptLabels: [] |
||||
|
|
||||
|
# Label to add before locking, such as `outdated`. Set to `false` to disable |
||||
|
lockLabel: false |
||||
|
|
||||
|
# Comment to post before locking. Set to `false` to disable |
||||
|
lockComment: > |
||||
|
This thread has been automatically locked since there has not been |
||||
|
any recent activity after it was closed. Please open a new issue for |
||||
|
related bugs. |
||||
|
|
||||
|
# Assign `resolved` as the reason for locking. Set to `false` to disable |
||||
|
setLockReason: true |
||||
|
|
||||
|
# Limit to only `issues` or `pulls` |
||||
|
# only: issues |
||||
|
|
||||
|
# Optionally, specify configuration settings just for `issues` or `pulls` |
||||
|
# issues: |
||||
|
# exemptLabels: |
||||
|
# - help-wanted |
||||
|
# lockLabel: outdated |
||||
|
|
||||
|
# pulls: |
||||
|
# daysUntilLock: 30 |
||||
|
|
||||
|
# Repository to extend settings from |
||||
|
# _extends: repo |
||||
@ -0,0 +1,15 @@ |
|||||
|
# Number of days of inactivity before an issue becomes stale |
||||
|
daysUntilStale: 60 |
||||
|
# Number of days of inactivity before a stale issue is closed |
||||
|
daysUntilClose: 7 |
||||
|
# Set to true to ignore issues in a milestone (defaults to false) |
||||
|
exemptMilestones: true |
||||
|
# Label to use when marking an issue as stale |
||||
|
staleLabel: inactive |
||||
|
# Comment to post when marking an issue as stale. Set to `false` to disable |
||||
|
markComment: > |
||||
|
This issue has been automatically marked as stale because it has not had |
||||
|
recent activity. It will be closed if no further activity occurs. Thank you |
||||
|
for your contributions. |
||||
|
# Comment to post when closing a stale issue. Set to `false` to disable |
||||
|
closeComment: false |
||||
@ -0,0 +1,30 @@ |
|||||
|
# Social/External Logins |
||||
|
|
||||
|
## ASP.NET Core MVC / Razor Pages UI |
||||
|
|
||||
|
The [Account Module](../Modules/Account.md) has already configured to handle social or external logins out of the box. You can follow the ASP.NET Core documentation to add a social/external login provider to your application. |
||||
|
|
||||
|
### Example: Facebook Authentication |
||||
|
|
||||
|
Follow the [ASP.NET Core Facebook integration document](https://docs.microsoft.com/en-us/aspnet/core/security/authentication/social/facebook-logins) to support the Facebook login for your application. |
||||
|
|
||||
|
#### Add the NuGet Package |
||||
|
|
||||
|
Add the [Microsoft.AspNetCore.Authentication.Facebook](https://www.nuget.org/packages/Microsoft.AspNetCore.Authentication.Facebook) package to your project. Based on your architecture, this can be `.Web`, `.IdentityServer` (for tiered setup) or `.Host` project. |
||||
|
|
||||
|
#### Configure the Provider |
||||
|
|
||||
|
Use the `.AddFacebook(...)` extension method in the `ConfigureServices` method of your [module](../Module-Development-Basics.md), to configure the client: |
||||
|
|
||||
|
````csharp |
||||
|
context.Services.AddAuthentication() |
||||
|
.AddFacebook(facebook => |
||||
|
{ |
||||
|
facebook.AppId = "..."; |
||||
|
facebook.AppSecret = "..."; |
||||
|
facebook.Scope.Add("email"); |
||||
|
facebook.Scope.Add("public_profile"); |
||||
|
}); |
||||
|
```` |
||||
|
|
||||
|
> It would be a better practice to use the `appsettings.json` or the ASP.NET Core User Secrets system to store your credentials, instead of a hard-coded value like that. Follow the [Microsoft's document](https://docs.microsoft.com/en-us/aspnet/core/security/authentication/social/facebook-logins) to learn the user secrets usage. |
||||
@ -0,0 +1,30 @@ |
|||||
|
# 社交/外部登录 |
||||
|
|
||||
|
## ASP.NET Core MVC / Razor Pages UI |
||||
|
|
||||
|
[帐户模块](../Modules/Account.md)已配置为开箱即用的处理社交或外部登录. 你可以按照ASP.NET Core文档向你的应用程序添加社交/外部登录提供程序. |
||||
|
|
||||
|
### 示例: Facebook 认证 |
||||
|
|
||||
|
按照[ASP.NET Core Facebook集成文档](https://docs.microsoft.com/zh-cn/aspnet/core/security/authentication/social/facebook-logins)向你应用程序添加Facebook登录. |
||||
|
|
||||
|
#### 添加NuGet包 |
||||
|
|
||||
|
添加[Microsoft.AspNetCore.Authentication.Facebook]包到你的项目. 基于你的架构,可能是 `.Web`,`.IdentityServer`(对于分层启动)或 `.Host` 项目. |
||||
|
|
||||
|
#### 配置提供程序 |
||||
|
|
||||
|
在你模块的 `ConfigureServices` 方法中使用 `.AddFacebook(...)` 扩展方法来配置客户端: |
||||
|
|
||||
|
````csharp |
||||
|
context.Services.AddAuthentication() |
||||
|
.AddFacebook(facebook => |
||||
|
{ |
||||
|
facebook.AppId = "..."; |
||||
|
facebook.AppSecret = "..."; |
||||
|
facebook.Scope.Add("email"); |
||||
|
facebook.Scope.Add("public_profile"); |
||||
|
}); |
||||
|
```` |
||||
|
|
||||
|
> 最佳实践是使用 `appsettings.json` 或ASP.NET Core用户机密系统来存储你的凭据,而不是像这样硬编码值. 请参阅[微软](https://docs.microsoft.com/en-us/aspnet/core/security/authentication/social/facebook-logins)文档了解如何使用用户机密. |
||||
@ -0,0 +1 @@ |
|||||
|
TODO.. |
||||
@ -0,0 +1,255 @@ |
|||||
|
# Web应用程序开发教程 - 第三章: 集成测试 |
||||
|
````json |
||||
|
//[doc-params] |
||||
|
{ |
||||
|
"UI": ["MVC","NG"], |
||||
|
"DB": ["EF","Mongo"] |
||||
|
} |
||||
|
```` |
||||
|
{{ |
||||
|
if UI == "MVC" |
||||
|
UI_Text="mvc" |
||||
|
else if UI == "NG" |
||||
|
UI_Text="angular" |
||||
|
else |
||||
|
UI_Text="?" |
||||
|
end |
||||
|
if DB == "EF" |
||||
|
DB_Text="Entity Framework Core" |
||||
|
else if DB == "Mongo" |
||||
|
DB_Text="MongoDB" |
||||
|
else |
||||
|
DB_Text="?" |
||||
|
end |
||||
|
}} |
||||
|
|
||||
|
## 关于本教程 |
||||
|
|
||||
|
在本系列教程中, 你将构建一个名为 `Acme.BookStore` 的用于管理书籍及其作者列表的基于ABP的应用程序. 它是使用以下技术开发的: |
||||
|
|
||||
|
* **{{DB_Text}}** 做为ORM提供程序. |
||||
|
* **{{UI_Value}}** 做为UI框架. |
||||
|
|
||||
|
本教程分为以下部分: |
||||
|
|
||||
|
- [Part 1: 创建服务端](Part-1.md) |
||||
|
- [Part 2: 图书列表页面](Part-2.md) |
||||
|
- [Part 3: 创建,更新和删除图书](Part-3.md) |
||||
|
- **Part 4: 集成测试**(本章) |
||||
|
- [Part 5: 授权](Part-5.md) |
||||
|
- [Part 6: 作者: 领域层](Part-6.md) |
||||
|
- [Part 7: 作者: 数据库集成](Part-7.md) |
||||
|
- [Part 8: 作者: 应用服务层](Part-8.md) |
||||
|
- [Part 9: 作者: 用户页面](Part-9.md) |
||||
|
- [Part 10: 图书到作者的关系](Part-10.md) |
||||
|
|
||||
|
## 下载源码 |
||||
|
|
||||
|
本教程根据你的**UI** 和 **Database**偏好有多个版,我们准备了两种可供下载的源码组合: |
||||
|
|
||||
|
* [MVC (Razor Pages) UI 与 EF Core](https://github.com/abpframework/abp-samples/tree/master/BookStore-Mvc-EfCore) |
||||
|
* [Angular UI 与 MongoDB](https://github.com/abpframework/abp-samples/tree/master/BookStore-Angular-MongoDb) |
||||
|
|
||||
|
## 解决方案中的测试项目 |
||||
|
|
||||
|
这一部分涵盖了 **服务器端** 测试. 解决方案中有多个测试项目: |
||||
|
|
||||
|
 |
||||
|
|
||||
|
每个项目用于测试相关的应用程序项目.测试项目使用以下库进行测试: |
||||
|
|
||||
|
* [xunit](https://xunit.github.io/) 作为主测试框架. |
||||
|
* [Shoudly](http://shouldly.readthedocs.io/en/latest/) 作为断言库. |
||||
|
* [NSubstitute](http://nsubstitute.github.io/) 作为模拟库. |
||||
|
|
||||
|
{{if DB=="EF"}} |
||||
|
|
||||
|
> 测试项目配置为使用 **SQLite内存** 作为数据库. 创建一个单独的数据库实例并使用数据种子系统进行初始化种子数据,为每个测试准备一个新的数据库. |
||||
|
|
||||
|
{{else if DB=="Mongo"}} |
||||
|
|
||||
|
> **[Mongo2Go](https://github.com/Mongo2Go/Mongo2Go)**库用于模拟MongoDB数据库. 创建一个单独的数据库实例并使用数据种子系统进行初始化种子数据,为每个测试准备一个新的数据库. |
||||
|
|
||||
|
{{end}} |
||||
|
|
||||
|
## 添加测试数据 |
||||
|
|
||||
|
如果你已经按照[第一部分](Part-1.md)中的描述创建了数据种子贡献者,则相同的数据也在测试中可用. 因此你可以跳过此部分. 如果你尚未创建种子贡献者,可以使用 `BookStoreTestDataSeedContributor` 来为要在以下测试中使用的相同数据提供种子. |
||||
|
|
||||
|
## 测试 BookAppService |
||||
|
|
||||
|
在 `Acme.BookStore.Application.Tests` 项目中创建一个名叫 `BookAppService_Tests` 的测试类: |
||||
|
|
||||
|
````csharp |
||||
|
using System.Threading.Tasks; |
||||
|
using Shouldly; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Acme.BookStore.Books |
||||
|
{ {{if DB=="Mongo"}} |
||||
|
[Collection(BookStoreTestConsts.CollectionDefinitionName)]{{end}} |
||||
|
public class BookAppService_Tests : BookStoreApplicationTestBase |
||||
|
{ |
||||
|
private readonly IBookAppService _bookAppService; |
||||
|
|
||||
|
public BookAppService_Tests() |
||||
|
{ |
||||
|
_bookAppService = GetRequiredService<IBookAppService>(); |
||||
|
} |
||||
|
|
||||
|
[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 == "1984"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
```` |
||||
|
|
||||
|
* 测试方法 `Should_Get_List_Of_Books` 直接使用 `BookAppService.GetListAsync` 方法来获取用户列表,并执行检查. |
||||
|
* 我们可以安全地检查 "1984" 这本书的名称,因为我们知道这本书可以在数据库中找到,我们已将其添加到种子数据中. |
||||
|
|
||||
|
新增测试方法,用以测试创建一个**合法**book实体的场景: |
||||
|
|
||||
|
````csharp |
||||
|
[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 = System.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<AbpValidationException>(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` 异常. |
||||
|
|
||||
|
最终的测试类如下所示: |
||||
|
|
||||
|
````csharp |
||||
|
using System; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Shouldly; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Volo.Abp.Validation; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Acme.BookStore.Books |
||||
|
{ {{if DB=="Mongo"}} |
||||
|
[Collection(BookStoreTestConsts.CollectionDefinitionName)]{{end}} |
||||
|
public class BookAppService_Tests : BookStoreApplicationTestBase |
||||
|
{ |
||||
|
private readonly IBookAppService _bookAppService; |
||||
|
|
||||
|
public BookAppService_Tests() |
||||
|
{ |
||||
|
_bookAppService = GetRequiredService<IBookAppService>(); |
||||
|
} |
||||
|
|
||||
|
[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 == "1984"); |
||||
|
} |
||||
|
|
||||
|
[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 = System.DateTime.Now, |
||||
|
Type = BookType.ScienceFiction |
||||
|
} |
||||
|
); |
||||
|
|
||||
|
//Assert |
||||
|
result.Id.ShouldNotBe(Guid.Empty); |
||||
|
result.Name.ShouldBe("New test book 42"); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public async Task Should_Not_Create_A_Book_Without_Name() |
||||
|
{ |
||||
|
var exception = await Assert.ThrowsAsync<AbpValidationException>(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")); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
```` |
||||
|
|
||||
|
打开**测试资源管理器**(测试 -> Windows -> 测试资源管理器)并**执行**所有测试: |
||||
|
|
||||
|
 |
||||
|
|
||||
|
恭喜你, **绿色图标**表示测试已成功通过! |
||||
|
|
||||
|
## 下一章 |
||||
|
|
||||
|
查看本教程的[下一章](Part-5.md). |
||||
@ -0,0 +1 @@ |
|||||
|
TODO.. |
||||
@ -0,0 +1 @@ |
|||||
|
TODO.. |
||||
@ -0,0 +1 @@ |
|||||
|
TODO.. |
||||
@ -0,0 +1 @@ |
|||||
|
TODO.. |
||||
@ -0,0 +1 @@ |
|||||
|
TODO.. |
||||
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 51 KiB |
|
After Width: | Height: | Size: 78 KiB |
|
After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 46 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 75 KiB |
|
After Width: | Height: | Size: 76 KiB |
|
After Width: | Height: | Size: 65 KiB |
|
After Width: | Height: | Size: 42 KiB |
|
After Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 35 KiB |
|
After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 92 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 9.5 KiB |
|
After Width: | Height: | Size: 72 KiB |
|
After Width: | Height: | Size: 62 KiB |
|
After Width: | Height: | Size: 82 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 58 KiB |
|
After Width: | Height: | Size: 33 KiB |
@ -0,0 +1,205 @@ |
|||||
|
# 轻松取消将你的观察取消订阅 |
||||
|
|
||||
|
`SubscriptionService` 是一个实用工具服务,它提供了一个简单的取消订阅Angular组件和指令中的RxJS可观察对象的功能. 请参见[为什么在实例销毁时要取消订阅可观察对象](https://angular.io/guide/lifecycle-hooks#cleaning-up-on-instance-destruction). |
||||
|
|
||||
|
## 入门 |
||||
|
|
||||
|
你必须在组件或指令级别提供 `SubscriptionService`,因为它没有在**根中提供**,而且它与组件/指令的生命周期同步. 只有在此之后,您才能注入并开始使用它。 |
||||
|
|
||||
|
```js |
||||
|
import { SubscriptionService } from '@abp/ng.core'; |
||||
|
|
||||
|
@Component({ |
||||
|
/* class metadata here */ |
||||
|
providers: [SubscriptionService], |
||||
|
}) |
||||
|
class DemoComponent { |
||||
|
count$ = interval(1000); |
||||
|
|
||||
|
constructor(private subscription: SubscriptionService) { |
||||
|
this.subscription.addOne(this.count$, console.log); |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
由 `count$` 发出的值将被记录下来,直到组件被销毁. 你不必手动退订. |
||||
|
|
||||
|
> 请不要尝试使用单例 `SubscriptionService`. 这是行不通的. |
||||
|
|
||||
|
## 用法 |
||||
|
|
||||
|
## 如何订阅可观察对象 |
||||
|
|
||||
|
你可以传递 `next` 函数和 `error` 函数. |
||||
|
|
||||
|
|
||||
|
|
||||
|
```js |
||||
|
@Component({ |
||||
|
/* class metadata here */ |
||||
|
providers: [SubscriptionService], |
||||
|
}) |
||||
|
class DemoComponent implements OnInit { |
||||
|
constructor(private subscription: SubscriptionService) {} |
||||
|
|
||||
|
ngOnInit() { |
||||
|
const source$ = interval(1000); |
||||
|
const nextFn = value => console.log(value * 2); |
||||
|
const errorFn = error => { |
||||
|
console.error(error); |
||||
|
return of(null); |
||||
|
}; |
||||
|
|
||||
|
this.subscription.addOne(source$, nextFn, errorFn); |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
或者,你可以传递一个观察者. |
||||
|
|
||||
|
```js |
||||
|
@Component({ |
||||
|
/* class metadata here */ |
||||
|
providers: [SubscriptionService], |
||||
|
}) |
||||
|
class DemoComponent implements OnInit { |
||||
|
constructor(private subscription: SubscriptionService) {} |
||||
|
|
||||
|
ngOnInit() { |
||||
|
const source$ = interval(1000); |
||||
|
const observer = { |
||||
|
next: value => console.log(value * 2), |
||||
|
complete: () => console.log('DONE'), |
||||
|
}; |
||||
|
|
||||
|
this.subscription.addOne(source$, observer); |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
`addOne` 方法返回单个订阅以便你以后使用它. 有关详细信息,请参见下面的主题. |
||||
|
|
||||
|
### 实例销毁之前如何退订 |
||||
|
|
||||
|
有两种方法可以做到这一点. 如果你不想再次订阅.可以使用 `closeAll` 方法. |
||||
|
|
||||
|
```js |
||||
|
@Component({ |
||||
|
/* class metadata here */ |
||||
|
providers: [SubscriptionService], |
||||
|
}) |
||||
|
class DemoComponent implements OnInit { |
||||
|
constructor(private subscription: SubscriptionService) {} |
||||
|
|
||||
|
ngOnInit() { |
||||
|
this.subscription.addOne(interval(1000), console.log); |
||||
|
} |
||||
|
|
||||
|
onSomeEvent() { |
||||
|
this.subscription.closeAll(); |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
这将清除所有订阅,你将无法再次订阅. 如果你打算添加另一个订阅,可以使用`reset`方法. |
||||
|
|
||||
|
```js |
||||
|
@Component({ |
||||
|
/* class metadata here */ |
||||
|
providers: [SubscriptionService], |
||||
|
}) |
||||
|
class DemoComponent implements OnInit { |
||||
|
constructor(private subscription: SubscriptionService) {} |
||||
|
|
||||
|
ngOnInit() { |
||||
|
this.subscription.addOne(interval(1000), console.log); |
||||
|
} |
||||
|
|
||||
|
onSomeEvent() { |
||||
|
this.subscription.reset(); |
||||
|
this.subscription.addOne(interval(1000), console.warn); |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
### 如何取消单个订阅 |
||||
|
|
||||
|
有时你可能需要取消订阅特定的订阅,但保留其他订阅. 在这种情况下,你可以使用 `closeOne` 方法. |
||||
|
|
||||
|
```js |
||||
|
@Component({ |
||||
|
/* class metadata here */ |
||||
|
providers: [SubscriptionService], |
||||
|
}) |
||||
|
class DemoComponent implements OnInit { |
||||
|
countSubscription: Subscription; |
||||
|
|
||||
|
constructor(private subscription: SubscriptionService) {} |
||||
|
|
||||
|
ngOnInit() { |
||||
|
this.countSubscription = this.subscription.addOne( |
||||
|
interval(1000), |
||||
|
console.log |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
onSomeEvent() { |
||||
|
this.subscription.closeOne(this.countSubscription); |
||||
|
console.log(this.countSubscription.closed); // true |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
### 如何从跟踪的订阅中删除单个订阅 |
||||
|
|
||||
|
你可能需要控制特定的订阅. 在这种情况下你可以使用 `removeOne` 方法将其从跟踪的订阅中删除. |
||||
|
|
||||
|
```js |
||||
|
@Component({ |
||||
|
/* class metadata here */ |
||||
|
providers: [SubscriptionService], |
||||
|
}) |
||||
|
class DemoComponent implements OnInit { |
||||
|
countSubscription: Subscription; |
||||
|
|
||||
|
constructor(private subscription: SubscriptionService) {} |
||||
|
|
||||
|
ngOnInit() { |
||||
|
this.countSubscription = this.subscription.addOne( |
||||
|
interval(1000), |
||||
|
console.log |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
onSomeEvent() { |
||||
|
this.subscription.removeOne(this.countSubscription); |
||||
|
console.log(this.countSubscription.closed); // false |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
### 如何检查是否全部取消订阅 |
||||
|
|
||||
|
使用 `isClosed` 检查 `closeAll` 是否被调用. |
||||
|
|
||||
|
```js |
||||
|
@Component({ |
||||
|
/* class metadata here */ |
||||
|
providers: [SubscriptionService], |
||||
|
}) |
||||
|
class DemoComponent implements OnInit { |
||||
|
constructor(private subscription: SubscriptionService) {} |
||||
|
|
||||
|
ngOnInit() { |
||||
|
this.subscription.addOne(interval(1000), console.log); |
||||
|
} |
||||
|
|
||||
|
onSomeEvent() { |
||||
|
console.log(this.subscription.isClosed); // false |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
## 下一步是什么? |
||||
|
|
||||
|
- [ListService](./List-Service.md) |
||||
|
Before Width: | Height: | Size: 8.1 KiB After Width: | Height: | Size: 106 KiB |
|
Before Width: | Height: | Size: 235 KiB After Width: | Height: | Size: 63 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 19 KiB |
@ -0,0 +1,3 @@ |
|||||
|
# Dynamic JavaScript HTTP API Proxies |
||||
|
|
||||
|
TODO |
||||
@ -0,0 +1,15 @@ |
|||||
|
using Newtonsoft.Json; |
||||
|
using Volo.Abp.Collections; |
||||
|
|
||||
|
namespace Volo.Abp.Json.Newtonsoft |
||||
|
{ |
||||
|
public class AbpNewtonsoftJsonSerializerOptions |
||||
|
{ |
||||
|
public ITypeList<JsonConverter> Converters { get; } |
||||
|
|
||||
|
public AbpNewtonsoftJsonSerializerOptions() |
||||
|
{ |
||||
|
Converters = new TypeList<JsonConverter>(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,7 @@ |
|||||
|
{ |
||||
|
"culture": "ar", |
||||
|
"texts": { |
||||
|
"DisplayName:Abp.Timing.Timezone": "المنطقة زمنية", |
||||
|
"Description:Abp.Timing.Timezone": "المنطقة الزمنية للتطبيق" |
||||
|
} |
||||
|
} |
||||
@ -1,34 +1,34 @@ |
|||||
{ |
{ |
||||
"culture": "ar", |
"culture": "ar", |
||||
"texts": { |
"texts": { |
||||
"'{0}' and '{1}' do not match.": "'{0}' and '{1}' do not match.", |
"'{0}' and '{1}' do not match.": "'{0}' و '{1}' غير متطابقان", |
||||
"The {0} field is not a valid credit card number.": "The {0} field is not a valid credit card number.", |
"The {0} field is not a valid credit card number.": "الحقل {0} لا يمثل رقم بطاقة ائتمان صالح.", |
||||
"{0} is not valid.": "{0} is not valid.", |
"{0} is not valid.": "{0} غير صالح.", |
||||
"The {0} field is not a valid e-mail address.": "The {0} field is not a valid e-mail address.", |
"The {0} field is not a valid e-mail address.": "الحقل {0} لا يمثل عنوان بريد إلكتروني صالح.", |
||||
"The {0} field only accepts files with the following extensions: {1}": "The {0} field only accepts files with the following extensions: {1}", |
"The {0} field only accepts files with the following extensions: {1}": "الحقل {0} يقبل الملفات ذات الامتدادات التالية فقط: {1}", |
||||
"The field {0} must be a string or array type with a maximum length of '{1}'.": "The field {0} must be a string or array type with a maximum length of '{1}'.", |
"The field {0} must be a string or array type with a maximum length of '{1}'.": "يجب أن يكون الحقل {0} عبارة عن سلسلة أو صفيف طوله '{1}' كحد أقصى.", |
||||
"The field {0} must be a string or array type with a minimum length of '{1}'.": "The field {0} must be a string or array type with a minimum length of '{1}'.", |
"The field {0} must be a string or array type with a minimum length of '{1}'.": "يجب أن يكون الحقل {0} عبارة عن سلسلة أو صفيف طوله كحد أدنى '{1}'.", |
||||
"The {0} field is not a valid phone number.": "The {0} field is not a valid phone number.", |
"The {0} field is not a valid phone number.": "الحقل {0} لا يمثل رقم هاتف صالح.", |
||||
"The field {0} must be between {1} and {2}.": "The field {0} must be between {1} and {2}.", |
"The field {0} must be between {1} and {2}.": "يجب أن يكون الحقل {0} بين {1} و {2}.", |
||||
"The field {0} must match the regular expression '{1}'.": "The field {0} must match the regular expression '{1}'.", |
"The field {0} must match the regular expression '{1}'.": "يجب أن يتطابق الحقل {0} مع التعبير النمطي '{1}'.", |
||||
"The {0} field is required.": "The {0} field is required.", |
"The {0} field is required.": "الحقل {0} إجباري.", |
||||
"The field {0} must be a string with a maximum length of {1}.": "The field {0} must be a string with a maximum length of {1}.", |
"The field {0} must be a string with a maximum length of {1}.": "يجب أن يكون الحقل {0} سلسلة أحرف طولها كحد أقصى {1}.", |
||||
"The field {0} must be a string with a minimum length of {2} and a maximum length of {1}.": "The field {0} must be a string with a minimum length of {2} and a maximum length of {1}.", |
"The field {0} must be a string with a minimum length of {2} and a maximum length of {1}.": "يجب أن يكون الحقل {0} سلسلة أحرف طولها {1} كحد أدنى و {2} كحد أقصى.", |
||||
"The {0} field is not a valid fully-qualified http, https, or ftp URL.": "The {0} field is not a valid fully-qualified http, https, or ftp URL.", |
"The {0} field is not a valid fully-qualified http, https, or ftp URL.": "الحقل {0} ليس عنوانا URL صالحًا مؤهلاً بالكامل سواء كان عنوان http أو https أو ftp", |
||||
"The field {0} is invalid.": "The field {0} is invalid.", |
"The field {0} is invalid.": "الحقل {0} غير صالح.", |
||||
"ThisFieldIsNotAValidCreditCardNumber.": "This field is not a valid credit card number.", |
"ThisFieldIsNotAValidCreditCardNumber.": "هذا الحقل لا يمثل رقم بطاقة ائتمان صالح.", |
||||
"ThisFieldIsNotValid.": "This field is not valid.", |
"ThisFieldIsNotValid.": "هذا الحقل غير صالح.", |
||||
"ThisFieldIsNotAValidEmailAddress.": "This field is not a valid e-mail address.", |
"ThisFieldIsNotAValidEmailAddress.": "هذا الحقل لا يمثل عنوان بريد إلكتروني صالح.", |
||||
"ThisFieldOnlyAcceptsFilesWithTheFollowingExtensions:{0}": "This field only accepts files with the following extensions: {0}", |
"ThisFieldOnlyAcceptsFilesWithTheFollowingExtensions:{0}": "هذا الحقل يقبل الملفات ذات الامتدادات التالية فقط: {0}", |
||||
"ThisFieldMustBeAStringOrArrayTypeWithAMaximumLengthoOf{0}": "This field must be a string or array type with a maximum length of '{0}'.", |
"ThisFieldMustBeAStringOrArrayTypeWithAMaximumLengthOf{0}": "هذا الحقل يجب أن يكون سلسلة أحرف أو صفيف لا يتعدى طوله '{0}'.", |
||||
"ThisFieldMustBeAStringOrArrayTypeWithAMinimumLengthOf{0}": "This field must be a string or array type with a minimum length of '{0}'.", |
"ThisFieldMustBeAStringOrArrayTypeWithAMinimumLengthOf{0}": " هذا الحقل يجب أن يكون عبارة عن سلسلة أو صفيف طوله كحد أدنى '{0}'.", |
||||
"ThisFieldIsNotAValidPhoneNumber.": "This field is not a valid phone number.", |
"ThisFieldIsNotAValidPhoneNumber.": "هذا الحقل لا يمثل رقم هاتف صالح.", |
||||
"ThisFieldMustBeBetween{0}And{1}": "This field must be between {0} and {1}.", |
"ThisFieldMustBeBetween{0}And{1}": "هذا الحقل يجب أن يكون بين {0} و {1}.", |
||||
"ThisFieldMustMatchTheRegularExpression{0}": "This field must match the regular expression '{0}'.", |
"ThisFieldMustMatchTheRegularExpression{0}": "هذا الحقل يجب أن يتطابق مع التعبير النمطي '{0}'.", |
||||
"ThisFieldIsRequired.": "This field is required.", |
"ThisFieldIsRequired.": "هذا الحقل إجباري.", |
||||
"ThisFieldMustBeAStringWithAMaximumLengthOf{0}": "This field must be a string with a maximum length of {0}.", |
"ThisFieldMustBeAStringWithAMaximumLengthOf{0}": "هذا الحقل يجب أن يكون سلسلة أحرف طولها كحد أقصى {0}.", |
||||
"ThisFieldMustBeAStringWithAMinimumLengthOf{1}AndAMaximumLengthOf{0}": "This field must be a string with a minimum length of {1} and a maximum length of {0}.", |
"ThisFieldMustBeAStringWithAMinimumLengthOf{1}AndAMaximumLengthOf{0}": "هذا الحقل يجب أن يكون سلسلة أحرف طولها {0} كحد أدنى و {1} كحد أقصى.", |
||||
"ThisFieldIsNotAValidFullyQualifiedHttpHttpsOrFtpUrl": "This field is not a valid fully-qualified http, https, or ftp URL.", |
"ThisFieldIsNotAValidFullyQualifiedHttpHttpsOrFtpUrl": "هذا الحقل ليس عنوانا URL صالحًا مؤهلاً بالكامل سواء كان عنوان http أو https أو ftp", |
||||
"ThisFieldIsInvalid.": "This field is invalid." |
"ThisFieldIsInvalid.": "هذا الحقل غير صالح." |
||||
} |
} |
||||
} |
} |
||||
@ -0,0 +1,7 @@ |
|||||
|
{ |
||||
|
"culture": "ar", |
||||
|
"texts": { |
||||
|
"HelloText": "مرحبا {0}", |
||||
|
"HowAreYou": "كيف حالكم ؟" |
||||
|
} |
||||
|
} |
||||