18
18
19
19
using System . Globalization ;
20
20
using Newtonsoft . Json ;
21
+ using System . Collections . Generic ;
22
+ using System ;
21
23
22
24
namespace OpenQA . Selenium . Remote
23
25
{
@@ -49,11 +51,27 @@ public Response(SessionId sessionId)
49
51
}
50
52
}
51
53
54
+ private Response ( Dictionary < string , object > rawResponse )
55
+ {
56
+ if ( rawResponse . ContainsKey ( "sessionId" ) )
57
+ {
58
+ this . responseSessionId = rawResponse [ "sessionId" ] . ToString ( ) ;
59
+ }
60
+
61
+ if ( rawResponse . ContainsKey ( "status" ) )
62
+ {
63
+ this . responseStatus = ( WebDriverResult ) Convert . ToInt32 ( rawResponse [ "status" ] ) ;
64
+ }
65
+
66
+ if ( rawResponse . ContainsKey ( "value" ) )
67
+ {
68
+ this . responseValue = rawResponse [ "value" ] ;
69
+ }
70
+ }
71
+
52
72
/// <summary>
53
73
/// Gets or sets the value from JSON.
54
74
/// </summary>
55
- [ JsonConverter ( typeof ( ResponseValueJsonConverter ) ) ]
56
- [ JsonProperty ( "value" ) ]
57
75
public object Value
58
76
{
59
77
get { return this . responseValue ; }
@@ -63,7 +81,6 @@ public object Value
63
81
/// <summary>
64
82
/// Gets or sets the session ID.
65
83
/// </summary>
66
- [ JsonProperty ( "sessionId" ) ]
67
84
public string SessionId
68
85
{
69
86
get { return this . responseSessionId ; }
@@ -73,7 +90,6 @@ public string SessionId
73
90
/// <summary>
74
91
/// Gets or sets the status value of the response.
75
92
/// </summary>
76
- [ JsonProperty ( "status" ) ]
77
93
public WebDriverResult Status
78
94
{
79
95
get { return this . responseStatus ; }
@@ -87,9 +103,9 @@ public WebDriverResult Status
87
103
/// <returns>A <see cref="Response"/> object described by the JSON string.</returns>
88
104
public static Response FromJson ( string value )
89
105
{
90
- JsonSerializerSettings settings = new JsonSerializerSettings ( ) ;
91
- settings . DateParseHandling = DateParseHandling . None ;
92
- return JsonConvert . DeserializeObject < Response > ( value , settings ) ;
106
+ Dictionary < string , object > deserializedResponse = JsonConvert . DeserializeObject < Dictionary < string , object > > ( value , new ResponseValueJsonConverter ( ) ) ;
107
+ Response response = new Response ( deserializedResponse ) ;
108
+ return response ;
93
109
}
94
110
95
111
/// <summary>
0 commit comments