-
-
Notifications
You must be signed in to change notification settings - Fork 738
feat: updated 'TitleBarOverlay' property to be passed as object #911
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
Changes from 4 commits
7927a95
21ae89b
d79b73e
14962e1
c0e7119
9bb7dcf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| namespace ElectronNET.API.Entities; | ||
|
|
||
| public class TitleBarOverlay | ||
| { | ||
| private readonly bool? _value; | ||
|
|
||
| public TitleBarOverlay() | ||
| { | ||
| } | ||
|
|
||
| private TitleBarOverlay(bool value) : this() => _value = value; | ||
|
|
||
| public string Color { get; set; } | ||
|
|
||
| public double Height { get; set; } | ||
|
|
||
| public string SymbolColor { get; set; } | ||
|
|
||
| public static implicit operator bool?(TitleBarOverlay titleBarOverlay) => titleBarOverlay?._value; | ||
|
|
||
| public static implicit operator TitleBarOverlay(bool value) => new(value); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| using ElectronNET.API.Entities; | ||
| using Newtonsoft.Json; | ||
| using System; | ||
|
|
||
| namespace ElectronNET.Converter; | ||
|
|
||
| public class TitleBarOverlayConverter : JsonConverter<TitleBarOverlay> | ||
| { | ||
| public override TitleBarOverlay ReadJson(JsonReader reader, Type objectType, TitleBarOverlay existingValue, bool hasExistingValue, JsonSerializer serializer) | ||
| { | ||
| if (reader.TokenType == JsonToken.Boolean) | ||
| { | ||
| return (bool)reader.Value; | ||
| } | ||
| else if (reader.TokenType == JsonToken.StartObject) | ||
| { | ||
| return serializer.Deserialize<TitleBarOverlay>(reader); | ||
| } | ||
| else | ||
| { | ||
| throw new JsonSerializationException("Invalid value for TitleBarOverlay. Expected true, false, or an object."); | ||
| } | ||
| } | ||
|
|
||
| public override void WriteJson(JsonWriter writer, TitleBarOverlay value, JsonSerializer serializer) | ||
| { | ||
| if (value is null) | ||
| { | ||
| writer.WriteNull(); | ||
| return; | ||
| } | ||
| var @bool = (bool?)value; | ||
| if (@bool.HasValue) | ||
| { | ||
| writer.WriteValue(@bool.Value); | ||
| } | ||
| else | ||
| { | ||
| serializer.Serialize(writer, value); | ||
| } | ||
| } | ||
| } | ||
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.