Skip to content

Commit

Permalink
Merge pull request #40 from Ali-YousefiTelori/develop
Browse files Browse the repository at this point in the history
fix parameter mismatch bug
  • Loading branch information
Ali-YousefiTelori authored Dec 24, 2023
2 parents 79f4eaa + 474febc commit 82cc585
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>0.0.0.20</Version>
<Version>0.0.0.21</Version>
<Description>client generated code.</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>microservice,Content,Contents,client</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,34 +118,44 @@ async Task ResolveContentLanguage(object contract, string language, HashSet<obje
return;
var type = contract.GetType();
mappedItems.Add(contract);
foreach (var property in type.GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance))
if (IsClass(type) && typeof(IEnumerable).IsAssignableFrom(type))
{
if (property.GetCustomAttribute<ContentLanguageAttribute>() != null)
foreach (var item in (IEnumerable)contract)
{
var contentResult = await _contentClient.GetByLanguageAsync(new GetByLanguageRequestContract()
{
Key = property.Name,
UniqueIdentity = GetUniqueIdentity(contract),
Language = language
});
if (contentResult.IsSuccess)
property.SetValue(contract, contentResult.Result.Data);
await ResolveContentLanguage(item, language, mappedItems);
}
else if (IsClass(property.PropertyType) && typeof(IEnumerable).IsAssignableFrom(property.PropertyType))
}
else
{
foreach (var property in type.GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance))
{
var items = property.GetValue(contract);
if (items == null)
continue;
foreach (var item in (IEnumerable)items)
if (property.GetCustomAttribute<ContentLanguageAttribute>() != null)
{
await ResolveContentLanguage(item, language, mappedItems);
var contentResult = await _contentClient.GetByLanguageAsync(new GetByLanguageRequestContract()
{
Key = property.Name,
UniqueIdentity = GetUniqueIdentity(contract),
Language = language
});
if (contentResult.IsSuccess)
property.SetValue(contract, contentResult.Result.Data);
}
else if (IsClass(property.PropertyType) && typeof(IEnumerable).IsAssignableFrom(property.PropertyType))
{
var items = property.GetValue(contract);
if (items == null)
continue;
foreach (var item in (IEnumerable)items)
{
await ResolveContentLanguage(item, language, mappedItems);
}
}
else if (IsClass(property.PropertyType))
{
var value = property.GetValue(contract);
if (value != null)
await ResolveContentLanguage(value, language, mappedItems);
}
}
else if (IsClass(property.PropertyType))
{
var value = property.GetValue(contract);
if (value != null)
await ResolveContentLanguage(value, language, mappedItems);
}
}
}
Expand Down

0 comments on commit 82cc585

Please sign in to comment.