Skip to content

Commit

Permalink
Merge pull request #35 from LayTec-AG/bugfix/enum-bools
Browse files Browse the repository at this point in the history
Bugfix/enum bools
  • Loading branch information
sean-mcl authored Aug 6, 2020
2 parents be770ce + 356dbc0 commit a022f96
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 6 additions & 0 deletions Plotly.Blazor.Generator/src/EnumConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,12 @@ public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions

if (rawToTransformed.TryGetValue(rawValue, out var enumInfo))
{
// Serialize boolean enums as bool, not as string
if (string.Equals(enumInfo.Name, "false", StringComparison.InvariantCultureIgnoreCase) || string.Equals(enumInfo.Name, "true", StringComparison.InvariantCultureIgnoreCase))
{
writer.WriteBooleanValue(bool.Parse(enumInfo.Name));
return;
}
writer.WriteStringValue(enumInfo.Name);
return;
}
Expand Down
6 changes: 6 additions & 0 deletions Plotly.Blazor/EnumConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,12 @@ public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions

if (rawToTransformed.TryGetValue(rawValue, out var enumInfo))
{
// Serialize boolean enums as bool, not as string
if (string.Equals(enumInfo.Name, "false", StringComparison.InvariantCultureIgnoreCase) || string.Equals(enumInfo.Name, "true", StringComparison.InvariantCultureIgnoreCase))
{
writer.WriteBooleanValue(bool.Parse(enumInfo.Name));
return;
}
writer.WriteStringValue(enumInfo.Name);
return;
}
Expand Down
6 changes: 3 additions & 3 deletions Plotly.Blazor/wwwroot/plotly-latest.min.js

Large diffs are not rendered by default.

0 comments on commit a022f96

Please sign in to comment.