-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added a nested Added a new file for the JSON converter template - Generated the JSON converter source each enum field
- Loading branch information
Showing
12 changed files
with
128 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
namespace {{ dto_namespace }}; | ||
using {{ dto_namespace }}.Abstractions; | ||
|
||
public partial {{ data_structure_type }} @{{ dto_type_name }} | ||
{ | ||
{{ compiler_generated_attributes }} | ||
public class {{ field_name }}JsonConverter : System.Text.Json.Serialization.JsonConverter<I{{ dto_type_name }}> | ||
{ | ||
public override bool CanConvert(type typeToConvert) => | ||
typeof(I{{ dto_type_name }}).IsAssignableFrom(typeToConvert); | ||
|
||
public override I{{ dto_type_name }} Read( | ||
ref Utf8JsonReader reader, | ||
type typeToConvert, | ||
JsonSerializerOptions options | ||
) => | ||
@{{ dto_type_name }}.Parse( | ||
reader.TokenType == JsonTokenType.String | ||
? reader.GetString() | ||
: reader.GetInt32().ToString() | ||
); | ||
|
||
public override void Write(Utf8JsonWriter writer, I{{ dto_type_name }} value, Jso options) => | ||
writer.WriteStringValue(value.ShortName); | ||
} | ||
|
||
public class {{ field_name }}JsonConverterAttribute : System.Text.Json.Serialization.JsonConverterAttribute | ||
{ | ||
public {{ field_name }}JsonConverterAttribute() : base(typeof({{ field_name }}JsonConverter)) { } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters