框架重构
清除多余的业务
This commit is contained in:
@@ -13,15 +13,15 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
{
|
||||
public static IServiceCollection AddAuthorizationService(this IServiceCollection services)
|
||||
{
|
||||
services.AddAuthorization(options =>
|
||||
{
|
||||
options.AddPolicy(PolicyName.Menu, polic =>
|
||||
{
|
||||
polic.AddRequirements(new CustomAuthorizationRequirement(PolicyEnum.MenuPermissions));
|
||||
});
|
||||
});
|
||||
//services.AddAuthorization(options =>
|
||||
//{
|
||||
// options.AddPolicy(PolicyName.Menu, polic =>
|
||||
// {
|
||||
// polic.AddRequirements(new CustomAuthorizationRequirement(PolicyEnum.MenuPermissions));
|
||||
// });
|
||||
//});
|
||||
|
||||
services.AddSingleton<IAuthorizationHandler, CustomAuthorizationHandler>();
|
||||
//services.AddSingleton<IAuthorizationHandler, CustomAuthorizationHandler>();
|
||||
return services;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Language;
|
||||
|
||||
namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
{
|
||||
public static class LocalizerExtend
|
||||
{
|
||||
public static IServiceCollection AddLocalizerService(this IServiceCollection services)
|
||||
{
|
||||
|
||||
services.AddLocalization();
|
||||
return services;
|
||||
}
|
||||
|
||||
public static void UseLocalizerService(this IApplicationBuilder app)
|
||||
{
|
||||
Result._local = app.ApplicationServices.GetService<IStringLocalizer<LocalLanguage>>();
|
||||
|
||||
var support = new[] { "zh", "en" };
|
||||
var local = new RequestLocalizationOptions().SetDefaultCulture(support[0])
|
||||
.AddSupportedCultures(support)
|
||||
.AddSupportedUICultures(support);
|
||||
app.UseRequestLocalization(local);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user