mirror of https://github.com/abpframework/abp.git
committed by
GitHub
10 changed files with 372 additions and 132 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> |
|||
|
|||
@ -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; } |
|||
} |
|||
|
|||
Loading…
Reference in new issue