Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix parameter mismatch bug #40

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading