Skip to content

Commit

Permalink
Merge pull request #82 from neozhu/supportcomplextype
Browse files Browse the repository at this point in the history
property complexType + "Dto"
  • Loading branch information
neozhu authored Aug 29, 2024
2 parents 01396f2 + d879b40 commit ecb91a6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
17 changes: 13 additions & 4 deletions src/Templatemap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ private static string splitCamelCase(string str)
private static string createDtoFieldDefinition(IntellisenseObject classObject)
{
var output = new StringBuilder();
foreach (var property in classObject.Properties.Where(x => x.Type.IsKnownType == true))
foreach (var property in classObject.Properties.Where(x => x.Type.IsDictionary == false))
{
output.Append($" [Description(\"{splitCamelCase(property.Name)}\")]\r\n");
if (property.Name == PRIMARYKEY)
Expand Down Expand Up @@ -231,9 +231,18 @@ private static string createDtoFieldDefinition(IntellisenseObject classObject)
output.Append($" public {property.Type.CodeName} {property.Name} {{get;set;}} \r\n");
break;
default:
if (property.Type.CodeName.Any(x => x == '?'))
if (property.Type.TypeScriptName == "any")
{
output.Append($" public {property.Type.CodeName} {property.Name} {{get;set;}} \r\n");
var complexType = property.Type.CodeName.Split('.').Last();
if (property.Type.Shape!=null && property.Type.Shape.Any())
{
complexType = complexType + "Dto";
}
else if (property.Type.IsArray)
{
complexType = $"List<{complexType}Dto>";
}
output.Append($" public {complexType}{(complexType.Any(x=>x== '?') ? "":"?")} {property.Name} {{get;set;}} \r\n");
}
else
{
Expand Down Expand Up @@ -338,7 +347,7 @@ private static string createMudTdDefinition(IntellisenseObject classObject)
{
output.Append(" ");
output.Append($" <MudText Typo=\"Typo.body2\" Class=\"mud-text-secondary\">@context.Description</MudText>\r\n");
}
}
output.Append(" ");
output.Append($" </div>\r\n");
output.Append(" ");
Expand Down
2 changes: 1 addition & 1 deletion src/Templates/Pages/.razor.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
</ToolBarContent>
<Columns>
<SelectColumn ShowInFooter="false"></SelectColumn>
<TemplateColumn CellStyle="width:60px" Title="@ConstantString.Actions" Sortable="false">
<TemplateColumn HeaderStyle="width:60px" Title="@ConstantString.Actions" Sortable="false">
<CellTemplate>
@if (_canEdit || _canDelete)
{
Expand Down

0 comments on commit ecb91a6

Please sign in to comment.