-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dotnet] [bidi] Enable implicit ways to specify page ranges for printing
- Loading branch information
1 parent
6c0df70
commit e031b8d
Showing
4 changed files
with
91 additions
and
19 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
28 changes: 28 additions & 0 deletions
28
dotnet/src/webdriver/BiDi/Communication/Json/Converters/PrintPageRangeConverter.cs
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,28 @@ | ||
using OpenQA.Selenium.BiDi.Modules.BrowsingContext; | ||
using System; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace OpenQA.Selenium.BiDi.Communication.Json.Converters; | ||
|
||
internal class PrintPageRangeConverter : JsonConverter<PrintPageRange> | ||
{ | ||
public override PrintPageRange Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public override void Write(Utf8JsonWriter writer, PrintPageRange value, JsonSerializerOptions options) | ||
{ | ||
// 5, "5-6", "-2", "2-" | ||
|
||
if (value.Start.HasValue && value.End.HasValue && value.Start == value.End) | ||
{ | ||
writer.WriteNumberValue(value.Start.Value); | ||
} | ||
else | ||
{ | ||
writer.WriteStringValue($"{value.Start}-{value.End}"); | ||
} | ||
} | ||
} |
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