mirror of https://github.com/abpframework/abp.git
59 changed files with 815 additions and 174 deletions
@ -1,20 +1,21 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="..\..\..\configureawait.props" /> |
|||
<Import Project="..\..\..\common.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netstandard2.0</TargetFramework> |
|||
<PackageId>Volo.Abp.MultiLingualObject</PackageId> |
|||
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback> |
|||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> |
|||
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> |
|||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\Volo.Abp.Localization\Volo.Abp.Localization.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="..\..\..\configureawait.props" /> |
|||
<Import Project="..\..\..\common.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netstandard2.0</TargetFramework> |
|||
<PackageId>Volo.Abp.MultiLingualObject</PackageId> |
|||
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback> |
|||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> |
|||
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> |
|||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> |
|||
<RootNamespace /> |
|||
<Nullable>enable</Nullable> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\Volo.Abp.Localization\Volo.Abp.Localization.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
|
|||
@ -0,0 +1,67 @@ |
|||
using JetBrains.Annotations; |
|||
|
|||
namespace Volo.Abp.UI.Navigation; |
|||
|
|||
public class ApplicationMenuGroup |
|||
{ |
|||
private string _displayName; |
|||
|
|||
/// <summary>
|
|||
/// Default <see cref="Order"/> value of a group item.
|
|||
/// </summary>
|
|||
public const int DefaultOrder = 1000; |
|||
|
|||
/// <summary>
|
|||
/// Unique name of the group in the application.
|
|||
/// </summary>
|
|||
[NotNull] |
|||
public string Name { get; } |
|||
|
|||
/// <summary>
|
|||
/// Display name of the group.
|
|||
/// </summary>
|
|||
[NotNull] |
|||
public string DisplayName { |
|||
get { return _displayName; } |
|||
set { |
|||
Check.NotNullOrWhiteSpace(value, nameof(value)); |
|||
_displayName = value; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Can be used to render the element with a specific Id for DOM selections.
|
|||
/// </summary>
|
|||
public string ElementId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// The Display order of the group.
|
|||
/// Default value: 1000.
|
|||
/// </summary>
|
|||
public int Order { get; set; } |
|||
|
|||
public ApplicationMenuGroup( |
|||
[NotNull] string name, |
|||
[NotNull] string displayName, |
|||
string elementId = null, |
|||
int order = DefaultOrder) |
|||
{ |
|||
Check.NotNullOrWhiteSpace(name, nameof(name)); |
|||
Check.NotNullOrWhiteSpace(displayName, nameof(displayName)); |
|||
|
|||
Name = name; |
|||
DisplayName = displayName; |
|||
ElementId = elementId; |
|||
Order = order; |
|||
} |
|||
|
|||
private string GetDefaultElementId() |
|||
{ |
|||
return "MenuGroup_" + Name; |
|||
} |
|||
|
|||
public override string ToString() |
|||
{ |
|||
return $"[ApplicationMenuGroup] Name = {Name}"; |
|||
} |
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
|
|||
namespace Volo.Abp.UI.Navigation; |
|||
|
|||
public class ApplicationMenuGroupList: List<ApplicationMenuGroup> |
|||
{ |
|||
public ApplicationMenuGroupList() |
|||
{ |
|||
|
|||
} |
|||
|
|||
public ApplicationMenuGroupList(int capacity) |
|||
: base(capacity) |
|||
{ |
|||
|
|||
} |
|||
|
|||
public ApplicationMenuGroupList(IEnumerable<ApplicationMenuGroup> collection) |
|||
: base(collection) |
|||
{ |
|||
|
|||
} |
|||
|
|||
public void Normalize() |
|||
{ |
|||
Order(); |
|||
} |
|||
|
|||
private void Order() |
|||
{ |
|||
var orderedItems = this.OrderBy(item => item.Order).ToArray(); |
|||
Clear(); |
|||
AddRange(orderedItems); |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
namespace Volo.Abp.UI.Navigation; |
|||
|
|||
public interface IHasMenuGroups |
|||
{ |
|||
/// <summary>
|
|||
/// Menu groups.
|
|||
/// </summary>
|
|||
ApplicationMenuGroupList Groups { get; } |
|||
} |
|||
@ -1,18 +1,21 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="..\..\..\common.test.props" /> |
|||
<Import Project="..\..\..\common.test.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net7.0</TargetFramework> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
<PropertyGroup> |
|||
<TargetFramework>net7.0</TargetFramework> |
|||
<RootNamespace /> |
|||
<Nullable>enable</Nullable> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\src\Volo.Abp.Autofac\Volo.Abp.Autofac.csproj" /> |
|||
<ProjectReference Include="..\..\src\Volo.Abp.MultiLingualObjects\Volo.Abp.MultiLingualObjects.csproj" /> |
|||
<ProjectReference Include="..\..\src\Volo.Abp.ObjectMapping\Volo.Abp.ObjectMapping.csproj" /> |
|||
<ProjectReference Include="..\AbpTestBase\AbpTestBase.csproj" /> |
|||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPackageVersion)" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\src\Volo.Abp.Autofac\Volo.Abp.Autofac.csproj" /> |
|||
<ProjectReference Include="..\..\src\Volo.Abp.MultiLingualObjects\Volo.Abp.MultiLingualObjects.csproj" /> |
|||
<ProjectReference Include="..\..\src\Volo.Abp.ObjectMapping\Volo.Abp.ObjectMapping.csproj" /> |
|||
<ProjectReference Include="..\..\src\Volo.Abp.AutoMapper\Volo.Abp.AutoMapper.csproj" /> |
|||
|
|||
<ProjectReference Include="..\AbpTestBase\AbpTestBase.csproj" /> |
|||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPackageVersion)" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
|
|||
@ -1,19 +1,34 @@ |
|||
using Volo.Abp.Autofac; |
|||
using Volo.Abp.Localization; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.ObjectMapping; |
|||
using Volo.Abp.Settings; |
|||
|
|||
namespace Volo.Abp.MultiLingualObjects; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpAutofacModule), |
|||
typeof(AbpLocalizationModule), |
|||
typeof(AbpSettingsModule), |
|||
typeof(AbpObjectMappingModule), |
|||
typeof(AbpMultiLingualObjectsModule), |
|||
typeof(AbpTestBaseModule) |
|||
)] |
|||
public class AbpMultiLingualObjectsTestModule : AbpModule |
|||
{ |
|||
} |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.Autofac; |
|||
using Volo.Abp.AutoMapper; |
|||
using Volo.Abp.Localization; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.ObjectMapping; |
|||
using Volo.Abp.Settings; |
|||
|
|||
namespace Volo.Abp.MultiLingualObjects; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpAutofacModule), |
|||
typeof(AbpLocalizationModule), |
|||
typeof(AbpSettingsModule), |
|||
typeof(AbpObjectMappingModule), |
|||
typeof(AbpMultiLingualObjectsModule), |
|||
typeof(AbpTestBaseModule), |
|||
typeof(AbpAutoMapperModule) |
|||
)] |
|||
public class AbpMultiLingualObjectsTestModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<AbpSettingOptions>(options => |
|||
{ |
|||
options.DefinitionProviders.Add<LocalizationSettingProvider>(); |
|||
}); |
|||
context.Services.AddAutoMapperObjectMapper<AbpMultiLingualObjectsTestModule>(); |
|||
Configure<AbpAutoMapperOptions>(options => |
|||
{ |
|||
options.AddMaps<AbpMultiLingualObjectsTestModule>(validate: true); |
|||
}); |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,23 @@ |
|||
namespace Volo.Abp.MultiLingualObjects; |
|||
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using global::AutoMapper; |
|||
using Volo.Abp.MultiLingualObjects.TestObjects; |
|||
|
|||
public class MultiLingualObjectTestProfile : Profile |
|||
{ |
|||
public MultiLingualObjectTestProfile() |
|||
{ |
|||
CreateMap<MultiLingualBook, MultiLingualBookDto>() |
|||
.ForMember(x => x.Name, |
|||
x => x.MapFrom((src, target, member, context) => |
|||
{ |
|||
if (context.Items.TryGetValue(nameof(MultiLingualBookTranslation), out var translationsRaw) && translationsRaw is IReadOnlyDictionary<Guid, MultiLingualBookTranslation> translations) |
|||
{ |
|||
return translations.GetValueOrDefault(src.Id)?.Name; |
|||
} |
|||
return null; |
|||
})); |
|||
} |
|||
} |
|||
@ -1,19 +1,19 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
|
|||
namespace Volo.Abp.MultiLingualObjects.TestObjects; |
|||
|
|||
public class MultiLingualBook : IMultiLingualObject<MultiLingualBookTranslation> |
|||
{ |
|||
public MultiLingualBook(Guid id, decimal price) |
|||
{ |
|||
Id = id; |
|||
Price = price; |
|||
} |
|||
|
|||
public Guid Id { get; } |
|||
|
|||
public decimal Price { get; set; } |
|||
|
|||
public ICollection<MultiLingualBookTranslation> Translations { get; set; } |
|||
} |
|||
using System; |
|||
using System.Collections.Generic; |
|||
|
|||
namespace Volo.Abp.MultiLingualObjects.TestObjects; |
|||
|
|||
public class MultiLingualBook : IMultiLingualObject<MultiLingualBookTranslation> |
|||
{ |
|||
public MultiLingualBook(Guid id, decimal price) |
|||
{ |
|||
Id = id; |
|||
Price = price; |
|||
} |
|||
|
|||
public Guid Id { get; } |
|||
|
|||
public decimal Price { get; set; } |
|||
|
|||
public ICollection<MultiLingualBookTranslation> Translations { get; set; } = new List<MultiLingualBookTranslation>(); |
|||
} |
|||
|
|||
@ -1,12 +1,12 @@ |
|||
using System; |
|||
|
|||
namespace Volo.Abp.MultiLingualObjects.TestObjects; |
|||
|
|||
public class MultiLingualBookDto |
|||
{ |
|||
public Guid Id { get; set; } |
|||
|
|||
public string Name { get; set; } |
|||
|
|||
public decimal Price { get; set; } |
|||
} |
|||
using System; |
|||
|
|||
namespace Volo.Abp.MultiLingualObjects.TestObjects; |
|||
|
|||
public class MultiLingualBookDto |
|||
{ |
|||
public Guid Id { get; set; } |
|||
|
|||
public string? Name { get; set; } |
|||
|
|||
public decimal Price { get; set; } |
|||
} |
|||
|
|||
@ -1,8 +1,8 @@ |
|||
namespace Volo.Abp.MultiLingualObjects.TestObjects; |
|||
|
|||
public class MultiLingualBookTranslation : IObjectTranslation |
|||
{ |
|||
public string Name { get; set; } |
|||
|
|||
public string Language { get; set; } |
|||
} |
|||
namespace Volo.Abp.MultiLingualObjects.TestObjects; |
|||
|
|||
public class MultiLingualBookTranslation : IObjectTranslation |
|||
{ |
|||
public string? Name { get; set; } |
|||
|
|||
public required string Language { get; set; } |
|||
} |
|||
|
|||
@ -0,0 +1,37 @@ |
|||
using System.Threading.Tasks; |
|||
using Microsoft.Extensions.Options; |
|||
using OpenIddict.Abstractions; |
|||
using OpenIddict.Server; |
|||
|
|||
namespace Volo.Abp.OpenIddict.WildcardDomains; |
|||
|
|||
public class AbpValidateAuthorizedParty : AbpOpenIddictWildcardDomainBase<OpenIddictServerHandlers.Session.ValidateAuthorizedParty, OpenIddictServerEvents.ValidateLogoutRequestContext> |
|||
{ |
|||
public static OpenIddictServerHandlerDescriptor Descriptor { get; } |
|||
= OpenIddictServerHandlerDescriptor.CreateBuilder<OpenIddictServerEvents.ValidateLogoutRequestContext>() |
|||
.UseScopedHandler<AbpValidateAuthorizedParty>() |
|||
.SetOrder(OpenIddictServerHandlers.Session.ValidateToken.Descriptor.Order + 1_000) |
|||
.SetType(OpenIddictServerHandlerType.BuiltIn) |
|||
.Build(); |
|||
|
|||
public AbpValidateAuthorizedParty( |
|||
IOptions<AbpOpenIddictWildcardDomainOptions> wildcardDomainsOptions, |
|||
IOpenIddictApplicationManager applicationManager) |
|||
: base(wildcardDomainsOptions, new OpenIddictServerHandlers.Session.ValidateAuthorizedParty(applicationManager)) |
|||
{ |
|||
Handler = new OpenIddictServerHandlers.Session.ValidateAuthorizedParty(applicationManager); |
|||
} |
|||
|
|||
public async override ValueTask HandleAsync(OpenIddictServerEvents.ValidateLogoutRequestContext context) |
|||
{ |
|||
Check.NotNull(context, nameof(context)); |
|||
Check.NotNull(context.IdentityTokenHintPrincipal, nameof(context.IdentityTokenHintPrincipal)); |
|||
|
|||
if (await CheckWildcardDomainAsync(context.PostLogoutRedirectUri)) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
await Handler.HandleAsync(context); |
|||
} |
|||
} |
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue