Skip to content

Commit e875b05

Browse files
committed
Add ConvertFrom support for DateTime and long
1 parent 49f1347 commit e875b05

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

dotnet/src/webdriver/BiDi/Modules/Script/LocalValue.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ public static LocalValue ConvertFrom(object? value)
6666
case double d:
6767
return new NumberLocalValue(d);
6868

69+
case long l:
70+
return new NumberLocalValue(l);
71+
72+
case DateTime dt:
73+
return new DateLocalValue(dt.ToString("o"));
74+
6975
case BigInteger bigInt:
7076
return new BigIntLocalValue(bigInt.ToString());
7177

@@ -75,7 +81,6 @@ public static LocalValue ConvertFrom(object? value)
7581
case IDictionary<string, string?> dictionary:
7682
{
7783
var bidiObject = new List<List<LocalValue>>(dictionary.Count);
78-
7984
foreach (var item in dictionary)
8085
{
8186
bidiObject.Add([new StringLocalValue(item.Key), ConvertFrom(item.Value)]);
@@ -87,7 +92,6 @@ public static LocalValue ConvertFrom(object? value)
8792
case IDictionary<string, object?> dictionary:
8893
{
8994
var bidiObject = new List<List<LocalValue>>(dictionary.Count);
90-
9195
foreach (var item in dictionary)
9296
{
9397
bidiObject.Add([new StringLocalValue(item.Key), ConvertFrom(item.Value)]);
@@ -99,7 +103,6 @@ public static LocalValue ConvertFrom(object? value)
99103
case IDictionary<int, object?> dictionary:
100104
{
101105
var bidiObject = new List<List<LocalValue>>(dictionary.Count);
102-
103106
foreach (var item in dictionary)
104107
{
105108
bidiObject.Add([ConvertFrom(item.Key), ConvertFrom(item.Value)]);
@@ -114,6 +117,7 @@ public static LocalValue ConvertFrom(object? value)
114117
case object:
115118
{
116119
const System.Reflection.BindingFlags Flags = System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance;
120+
117121
var properties = value.GetType().GetProperties(Flags);
118122

119123
var values = new List<List<LocalValue>>(properties.Length);

0 commit comments

Comments
 (0)