Skip to content

Commit 62e39b6

Browse files
committed
Merge branch 'dev'
2 parents e9390da + 3010b77 commit 62e39b6

File tree

67 files changed

+1037
-341
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1037
-341
lines changed

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
configuration: Release
2-
version: 2.0.0-beta{build}
2+
version: 2.1.0-beta{build}
33
image: Visual Studio 2017
44

55
nuget:

common.props

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
<Project>
22
<PropertyGroup>
3-
<Version>2.0.2</Version>
3+
<Version>2.1.0-beta1</Version>
44
<NoWarn>$(NoWarn);CS1591</NoWarn>
55
<PackageIconUrl>http://www.aspnetboilerplate.com/images/abp_nupkg.png</PackageIconUrl>
66
<PackageProjectUrl>http://www.aspnetboilerplate.com/</PackageProjectUrl>
77
<PackageLicenseUrl>https://github.com/aspnetboilerplate/aspnetboilerplate/blob/master/LICENSE</PackageLicenseUrl>
88
<RepositoryType>git</RepositoryType>
99
<RepositoryUrl>https://github.com/aspnetboilerplate/aspnetboilerplate</RepositoryUrl>
1010
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<PackageReference Include="SourceLink.Create.CommandLine" Version="2.1.2" PrivateAssets="All" />
14+
</ItemGroup>
15+
1116
</Project>

doc/WebSite/Repositories.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ <h5 id="DocGettingSingleEntity">
107107
than an Id. So, you can write a lambda expression to get an Entity. Example
108108
usages:</p>
109109
<pre>var person = _personRepository.Get(42);
110-
var person = _personRepository.Single(p =&gt; p.Name == "Halil İbrahim Kalkan");</pre>
110+
var person = _personRepository.Single(p =&gt; p.Name == "John");</pre>
111111
<p>Notice that <strong>Single </strong>method throws
112112
exception if there is no entity with given conditions or there are more
113113
than one entity.</p>

nupkg/pack.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,12 @@ $projects = (
3333
"Abp.Castle.Log4Net",
3434
"Abp.TestBase",
3535
"Abp.AspNetCore.TestBase",
36-
"Abp.Web.Resources"
36+
"Abp.Web.Resources"
3737
)
3838

3939
# Rebuild solution
4040
Set-Location $slnPath
4141
& dotnet restore
42-
& dotnet msbuild /t:Rebuild /p:Configuration=Release
4342

4443
# Copy all nuget packages to the pack folder
4544
foreach($project in $projects) {
@@ -48,7 +47,8 @@ foreach($project in $projects) {
4847

4948
# Create nuget pack
5049
Set-Location $projectFolder
51-
& dotnet msbuild /t:pack /p:Configuration=Release /p:IncludeSymbols=true
50+
Remove-Item -Recurse (Join-Path $projectFolder "bin/Release")
51+
& dotnet msbuild /t:pack /p:Configuration=Release /p:IncludeSymbols=true /p:SourceLinkCreate=true
5252

5353
# Copy nuget package
5454
$projectPackPath = Join-Path $projectFolder ("/bin/Release/" + $project + ".*.nupkg")

src/Abp.AspNetCore.TestBase/Abp.AspNetCore.TestBase.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
</ItemGroup>
3535

3636
<ItemGroup>
37-
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="1.1.1" />
37+
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="1.1.2" />
3838
</ItemGroup>
3939

4040
<ItemGroup Condition=" '$(TargetFramework)' == 'net46' ">

src/Abp.AspNetCore/Abp.AspNetCore.csproj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
</ItemGroup>
3535

3636
<ItemGroup>
37-
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
38-
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
37+
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" />
38+
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.2" />
3939
<PackageReference Include="Castle.LoggingFacility.MsLogging" Version="2.0.0" />
4040
<PackageReference Include="Castle.Windsor.MsDependencyInjection" Version="2.0.0" />
4141
</ItemGroup>
@@ -46,4 +46,8 @@
4646
<Reference Include="System.Transactions" />
4747
</ItemGroup>
4848

49+
<ItemGroup>
50+
<Folder Include="Localization\AspNetCore\" />
51+
</ItemGroup>
52+
4953
</Project>

src/Abp.AspNetCore/AspNetCore/AbpApplicationBuilderExtensions.cs

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,48 @@
1-
using System.Globalization;
1+
using System;
22
using System.Linq;
33
using Abp.AspNetCore.EmbeddedResources;
44
using Abp.AspNetCore.Localization;
5-
using Abp.AspNetCore.Mvc.Views;
65
using Abp.Dependency;
76
using Abp.Localization;
87
using Castle.LoggingFacility.MsLogging;
8+
using JetBrains.Annotations;
99
using Microsoft.AspNetCore.Builder;
1010
using Microsoft.AspNetCore.Localization;
1111
using Microsoft.Extensions.DependencyInjection;
1212
using Microsoft.Extensions.Logging;
1313

1414
namespace Abp.AspNetCore
1515
{
16-
public static class AbpApplicationBuilderExtensions
16+
public static class AbpApplicationBuilderExtensions
1717
{
1818
public static void UseAbp(this IApplicationBuilder app)
1919
{
20-
AddCastleLoggerFactory(app);
20+
app.UseAbp(null);
21+
}
2122

22-
InitializeAbp(app);
23+
public static void UseAbp([NotNull] this IApplicationBuilder app, Action<AbpApplicationBuilderOptions> optionsAction)
24+
{
25+
Check.NotNull(app, nameof(app));
2326

24-
ConfigureRequestLocalization(app);
25-
}
27+
var options = new AbpApplicationBuilderOptions();
28+
optionsAction?.Invoke(options);
29+
30+
if (options.UseCastleLoggerFactory)
31+
{
32+
app.UseCastleLoggerFactory();
33+
}
34+
35+
InitializeAbp(app);
2636

27-
public static void UseEmbeddedFiles(this IApplicationBuilder app)
37+
if (options.UseAbpRequestLocalization)
38+
{
39+
//TODO: This should be added later than authorization middleware!
40+
app.UseAbpRequestLocalization();
41+
}
42+
}
43+
44+
public static void UseEmbeddedFiles(this IApplicationBuilder app)
2845
{
29-
//TODO: Can improve it or create a custom middleware?
3046
app.UseStaticFiles(
3147
new StaticFileOptions
3248
{
@@ -43,7 +59,7 @@ private static void InitializeAbp(IApplicationBuilder app)
4359
abpBootstrapper.Initialize();
4460
}
4561

46-
private static void AddCastleLoggerFactory(IApplicationBuilder app)
62+
public static void UseCastleLoggerFactory(this IApplicationBuilder app)
4763
{
4864
var castleLoggerFactory = app.ApplicationServices.GetService<Castle.Core.Logging.ILoggerFactory>();
4965
if (castleLoggerFactory == null)
@@ -56,35 +72,32 @@ private static void AddCastleLoggerFactory(IApplicationBuilder app)
5672
.AddCastleLogger(castleLoggerFactory);
5773
}
5874

59-
private static void ConfigureRequestLocalization(IApplicationBuilder app)
75+
public static void UseAbpRequestLocalization(this IApplicationBuilder app, Action<RequestLocalizationOptions> optionsAction = null)
6076
{
6177
var iocResolver = app.ApplicationServices.GetRequiredService<IIocResolver>();
6278
using (var languageManager = iocResolver.ResolveAsDisposable<ILanguageManager>())
6379
{
64-
var defaultLanguage = languageManager.Object
65-
.GetLanguages()
66-
.FirstOrDefault(l => l.IsDefault);
67-
68-
if (defaultLanguage == null)
69-
{
70-
return;
71-
}
72-
7380
var supportedCultures = languageManager.Object
7481
.GetLanguages()
7582
.Select(l => CultureInfoHelper.Get(l.Name))
7683
.ToArray();
7784

78-
var defaultCulture = new RequestCulture(defaultLanguage.Name);
79-
8085
var options = new RequestLocalizationOptions
8186
{
82-
DefaultRequestCulture = defaultCulture,
8387
SupportedCultures = supportedCultures,
8488
SupportedUICultures = supportedCultures
8589
};
8690

91+
var userProvider = new UserRequestCultureProvider();
92+
8793
options.RequestCultureProviders.Insert(0, new AbpLocalizationHeaderRequestCultureProvider());
94+
options.RequestCultureProviders.Insert(2, userProvider);
95+
options.RequestCultureProviders.Insert(4, new DefaultRequestCultureProvider());
96+
97+
optionsAction?.Invoke(options);
98+
99+
//TODO: Find cookie provider, set to UserRequestCultureProvider to set user's setting!!!
100+
userProvider.CookieProvider = options.RequestCultureProviders.FirstOrDefault(p => p is CookieRequestCultureProvider);
88101

89102
app.UseRequestLocalization(options);
90103
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
namespace Abp.AspNetCore
2+
{
3+
public class AbpApplicationBuilderOptions
4+
{
5+
/// <summary>
6+
/// Default: true.
7+
/// </summary>
8+
public bool UseCastleLoggerFactory { get; set; }
9+
10+
/// <summary>
11+
/// Default: true.
12+
/// </summary>
13+
public bool UseAbpRequestLocalization { get; set; }
14+
15+
public AbpApplicationBuilderOptions()
16+
{
17+
UseCastleLoggerFactory = true;
18+
UseAbpRequestLocalization = true;
19+
}
20+
}
21+
}

src/Abp.AspNetCore/AspNetCore/AbpAspNetCoreModule.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Linq;
2-
using System.Reflection;
32
using Abp.AspNetCore.Configuration;
43
using Abp.AspNetCore.MultiTenancy;
54
using Abp.AspNetCore.Mvc.Auditing;
@@ -12,7 +11,6 @@
1211
using Abp.Reflection.Extensions;
1312
using Abp.Runtime.Session;
1413
using Abp.Web;
15-
using Abp.Web.MultiTenancy;
1614
using Abp.Web.Security.AntiForgery;
1715
using Microsoft.AspNetCore.Antiforgery;
1816
using Microsoft.AspNetCore.Http;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System.Threading.Tasks;
2+
using Abp.Configuration;
3+
using Abp.Extensions;
4+
using Abp.Localization;
5+
using Microsoft.AspNetCore.Http;
6+
using Microsoft.AspNetCore.Localization;
7+
using Microsoft.Extensions.DependencyInjection;
8+
9+
namespace Abp.AspNetCore.Localization
10+
{
11+
public class DefaultRequestCultureProvider : RequestCultureProvider
12+
{
13+
public override async Task<ProviderCultureResult> DetermineProviderCultureResult(HttpContext httpContext)
14+
{
15+
var settingManager = httpContext.RequestServices.GetRequiredService<ISettingManager>();
16+
17+
var culture = await settingManager.GetSettingValueAsync(LocalizationSettingNames.DefaultLanguage);
18+
19+
if (culture.IsNullOrEmpty())
20+
{
21+
return null;
22+
}
23+
24+
return new ProviderCultureResult(culture, culture);
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)