Browse Source

Merge remote-tracking branch 'abpframework/dev' into Translate

pull/1966/head
liangshiwei 7 years ago
parent
commit
1fc5fccf7d
  1. 87
      docs/en/Caching.md
  2. 10
      docs/en/Index.md
  3. 14
      framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs
  4. 2
      modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/en.json
  5. 2
      modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/zh-Hans.json
  6. 2
      modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml
  7. 2
      modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml
  8. 2
      npm/packs/core/src/abp.css

87
docs/en/Caching.md

@ -80,6 +80,93 @@ public class BookService : ITransientDependency
Other methods of the `IDistributedCache<BookCacheItem>` are same as ASP.NET Core's `IDistributedCache` interface, so you can refer [it's documentation](https://docs.microsoft.com/en-us/aspnet/core/performance/caching/distributed). Other methods of the `IDistributedCache<BookCacheItem>` are same as ASP.NET Core's `IDistributedCache` interface, so you can refer [it's documentation](https://docs.microsoft.com/en-us/aspnet/core/performance/caching/distributed).
## `IDistributedCache<TCacheItem, TCacheKey>` Interface
`IDistributedCache<TCacheItem>` interface assumes that the type of your cache key is `string` (so, you need to manually convert your key to string if you need to use a different kind of cache key). `IDistributedCache<TCacheItem, TCacheKey>` can be used when your cache key type is not `string`.
### Usage
An example class to store an item in the cache:
````csharp
public class BookCacheItem
{
public string Name { get; set; }
public float Price { get; set; }
}
````
Example usage (assumes that your cache key type is `Guid`):
````csharp
public class BookService : ITransientDependency
{
private readonly IDistributedCache<BookCacheItem, Guid> _cache;
public BookService(IDistributedCache<BookCacheItem, Guid> cache)
{
_cache = cache;
}
public async Task<BookCacheItem> GetAsync(Guid bookId)
{
return await _cache.GetOrAddAsync(
bookId, //Guid type used as the cache key
async () => await GetBookFromDatabaseAsync(bookId),
() => new DistributedCacheEntryOptions
{
AbsoluteExpiration = DateTimeOffset.Now.AddHours(1)
}
);
}
private Task<BookCacheItem> GetBookFromDatabaseAsync(Guid bookId)
{
//TODO: get from database
}
}
````
* This sample service uses the `GetOrAddAsync()` method to get a book item from the cache.
* Since cache explicitly implemented as using `Guid` as cache key, `Guid` value passed to `_cache_GetOrAddAsync()` method.
`IDistributedCache<TCacheItem, TCacheKey>` internally uses `ToString()` method of the key object to convert it to a string. If you need to use a complex object as the cache key, you need to override `ToString` method of your class.
An example class that is used as a cache key:
````csharp
public class UserInOrganizationCacheKey
{
public Guid UserId { get; set; }
public Guid OrganizationId { get; set; }
//Builds the cache key
public override string ToString()
{
return $"{UserId}_{OrganizationId}";
}
}
````
Example usage:
````csharp
public class BookService : ITransientDependency
{
private readonly IDistributedCache<UserCacheItem, UserInOrganizationCacheKey> _cache;
public BookService(
IDistributedCache<UserCacheItem, UserInOrganizationCacheKey> cache)
{
_cache = cache;
}
...
}
````
### DistributedCacheOptions ### DistributedCacheOptions
TODO TODO

10
docs/en/Index.md

@ -4,18 +4,12 @@ ABP is an **open source application framework** focused on ASP.NET Core based we
Explore the left navigation menu to deep dive in the documentation. Explore the left navigation menu to deep dive in the documentation.
## Project Status
ABP is the **next generation** of the open source [ASP.NET Boilerplate](https://aspnetboilerplate.com/) framework. It's currently in preview stage and not ready to use in production. The documentation is still in progress and it is far from complete.
For short-term and production level applications, it's suggested to use [ASP.NET Boilerplate](https://aspnetboilerplate.com/) framework which has rich feature set, mature, actively maintained and up-to-date.
## Getting Started ## Getting Started
Easiest way to start a new project with ABP is to use the startup templates: Easiest way to start a new project with ABP is to use the startup templates:
* [ASP.NET Core MVC (Razor Pages) UI Template](Getting-Started-AspNetCore-MVC-Template.md) * [ASP.NET Core MVC (Razor Pages) UI Startup Template](Getting-Started-AspNetCore-MVC-Template.md)
* [Angular UI Template](Getting-Started-Angular-Template.md) * [Angular UI Startup Template](Getting-Started-Angular-Template.md)
If you want to start from scratch (with an empty project) then manually install the ABP Framework and use the following tutorials: If you want to start from scratch (with an empty project) then manually install the ABP Framework and use the following tutorials:

14
framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs

@ -19,13 +19,11 @@ namespace Volo.Abp.Caching
where TCacheItem : class where TCacheItem : class
{ {
public DistributedCache( public DistributedCache(
IOptions<CacheOptions> cacheOption, IOptions<AbpDistributedCacheOptions> distributedCacheOption,
IOptions<DistributedCacheOptions> distributedCacheOption,
IDistributedCache cache, IDistributedCache cache,
ICancellationTokenProvider cancellationTokenProvider, ICancellationTokenProvider cancellationTokenProvider,
IDistributedCacheSerializer serializer, IDistributedCacheSerializer serializer,
ICurrentTenant currentTenant) : base( ICurrentTenant currentTenant) : base(
cacheOption: cacheOption,
distributedCacheOption: distributedCacheOption, distributedCacheOption: distributedCacheOption,
cache: cache, cache: cache,
cancellationTokenProvider: cancellationTokenProvider, cancellationTokenProvider: cancellationTokenProvider,
@ -62,12 +60,9 @@ namespace Volo.Abp.Caching
protected DistributedCacheEntryOptions DefaultCacheOptions; protected DistributedCacheEntryOptions DefaultCacheOptions;
private readonly AbpDistributedCacheOptions _cacheOption;
private readonly AbpDistributedCacheOptions _distributedCacheOption; private readonly AbpDistributedCacheOptions _distributedCacheOption;
public DistributedCache( public DistributedCache(
IOptions<AbpDistributedCacheOptions> cacheOption,
IOptions<AbpDistributedCacheOptions> distributedCacheOption, IOptions<AbpDistributedCacheOptions> distributedCacheOption,
IDistributedCache cache, IDistributedCache cache,
ICancellationTokenProvider cancellationTokenProvider, ICancellationTokenProvider cancellationTokenProvider,
@ -75,7 +70,6 @@ namespace Volo.Abp.Caching
ICurrentTenant currentTenant) ICurrentTenant currentTenant)
{ {
_distributedCacheOption = distributedCacheOption.Value; _distributedCacheOption = distributedCacheOption.Value;
_cacheOption = cacheOption.Value;
Cache = cache; Cache = cache;
CancellationTokenProvider = cancellationTokenProvider; CancellationTokenProvider = cancellationTokenProvider;
Logger = NullLogger<DistributedCache<TCacheItem, TCacheKey>>.Instance; Logger = NullLogger<DistributedCache<TCacheItem, TCacheKey>>.Instance;
@ -88,7 +82,7 @@ namespace Volo.Abp.Caching
} }
protected virtual string NormalizeKey(TCacheKey key) protected virtual string NormalizeKey(TCacheKey key)
{ {
var normalizedKey = "c:" + CacheName + ",k:" + _cacheOption.KeyPrefix + key.ToString(); var normalizedKey = "c:" + CacheName + ",k:" + _distributedCacheOption.KeyPrefix + key.ToString();
if (!IgnoreMultiTenancy && CurrentTenant.Id.HasValue) if (!IgnoreMultiTenancy && CurrentTenant.Id.HasValue)
{ {
@ -100,7 +94,7 @@ namespace Volo.Abp.Caching
protected virtual DistributedCacheEntryOptions GetDefaultCacheEntryOptions() protected virtual DistributedCacheEntryOptions GetDefaultCacheEntryOptions()
{ {
foreach (var configure in _cacheOption.CacheConfigurators) foreach (var configure in _distributedCacheOption.CacheConfigurators)
{ {
var options = configure.Invoke(CacheName); var options = configure.Invoke(CacheName);
if (options != null) if (options != null)
@ -108,7 +102,7 @@ namespace Volo.Abp.Caching
return options; return options;
} }
} }
return _cacheOption.GlobalCacheEntryOptions; return _distributedCacheOption.GlobalCacheEntryOptions;
} }
protected virtual void SetDefaultOptions() protected virtual void SetDefaultOptions()

2
modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/en.json

@ -14,6 +14,8 @@
"Login": "Login", "Login": "Login",
"Cancel": "Cancel", "Cancel": "Cancel",
"Register": "Register", "Register": "Register",
"AreYouANewUser": "Are you a new user?",
"AlreadyRegistered": "Already registered?",
"InvalidLoginRequest": "Invalid login request", "InvalidLoginRequest": "Invalid login request",
"ThereAreNoLoginSchemesConfiguredForThisClient": "There are no login schemes configured for this client.", "ThereAreNoLoginSchemesConfiguredForThisClient": "There are no login schemes configured for this client.",
"LogInUsingYourProviderAccount": "Log in using your {0} account", "LogInUsingYourProviderAccount": "Log in using your {0} account",

2
modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/zh-Hans.json

@ -14,6 +14,8 @@
"Login": "登录", "Login": "登录",
"Cancel": "取消", "Cancel": "取消",
"Register": "注册", "Register": "注册",
"AreYouANewUser": "你是新用户吗?",
"AlreadyRegistered": "已经注册过了?",
"InvalidLoginRequest": "登录请求无效", "InvalidLoginRequest": "登录请求无效",
"ThereAreNoLoginSchemesConfiguredForThisClient": "没有为此客户端配置登录方案.", "ThereAreNoLoginSchemesConfiguredForThisClient": "没有为此客户端配置登录方案.",
"LogInUsingYourProviderAccount": "使用你的{0}帐户登录" "LogInUsingYourProviderAccount": "使用你的{0}帐户登录"

2
modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml

@ -11,7 +11,7 @@
@if (string.Equals(await SettingProvider.GetOrNullAsync(AccountSettingNames.IsSelfRegistrationEnabled), "true", StringComparison.OrdinalIgnoreCase)) @if (string.Equals(await SettingProvider.GetOrNullAsync(AccountSettingNames.IsSelfRegistrationEnabled), "true", StringComparison.OrdinalIgnoreCase))
{ {
<strong> <strong>
Are you new user? @L["AreYouANewUser"]
<a href="@Url.Page("./Register", new {returnUrl = Model.ReturnUrl, returnUrlHash = Model.ReturnUrlHash})" class="text-decoration-none">@L["Register"]</a> <a href="@Url.Page("./Register", new {returnUrl = Model.ReturnUrl, returnUrlHash = Model.ReturnUrlHash})" class="text-decoration-none">@L["Register"]</a>
</strong> </strong>
} }

2
modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml

@ -6,7 +6,7 @@
<div class="card-body p-5"> <div class="card-body p-5">
<h4>@L["Register"]</h4> <h4>@L["Register"]</h4>
<strong> <strong>
Already registered? @L["AlreadyRegistered"]
<a href="@Url.Page("./Login", new {returnUrl = Model.ReturnUrl, returnUrlHash = Model.ReturnUrlHash})" class="text-decoration-none">@L["Login"]</a> <a href="@Url.Page("./Login", new {returnUrl = Model.ReturnUrl, returnUrlHash = Model.ReturnUrlHash})" class="text-decoration-none">@L["Login"]</a>
</strong> </strong>
<form method="post" class="mt-4"> <form method="post" class="mt-4">

2
npm/packs/core/src/abp.css

@ -14,7 +14,7 @@
left: 0; left: 0;
width: 100%; width: 100%;
height: 100%; height: 100%;
z-index: 999999999; z-index: 102;
background-color: #fff; background-color: #fff;
opacity: .8; opacity: .8;
transition: opacity .25s; transition: opacity .25s;

Loading…
Cancel
Save