-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Expand file tree
/
Copy pathDevToolsMethodResponse.cs
More file actions
47 lines (40 loc) · 1.21 KB
/
DevToolsMethodResponse.cs
File metadata and controls
47 lines (40 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright © 2020 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
using System.IO;
using System.Runtime.Serialization.Json;
using System.Text;
namespace CefSharp.DevTools
{
/// <summary>
/// DevTools Method Response
/// </summary>
public class DevToolsMethodResponse
{
/// <summary>
/// MessageId
/// </summary>
public int MessageId { get; set; }
/// <summary>
/// Success
/// </summary>
public bool Success { get; set; }
/// <summary>
/// Method Response as Json string
/// </summary>
public string ResponseAsJsonString { get; set; }
internal T DeserializeJson<T>()
{
if (Success)
{
var bytes = Encoding.UTF8.GetBytes(ResponseAsJsonString);
using (var ms = new MemoryStream(bytes))
{
var dcs = new DataContractJsonSerializer(typeof(T));
return (T)dcs.ReadObject(ms);
}
}
throw new DevToolsClientException(ResponseAsJsonString);
}
}
}