forked from SeleniumHQ/selenium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDevToolsCommandData.cs
107 lines (96 loc) · 4.19 KB
/
DevToolsCommandData.cs
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// <copyright file="DevToolsCommandData.cs" company="Selenium Committers">
// Licensed to the Software Freedom Conservancy (SFC) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The SFC licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
// </copyright>
using System;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Threading;
#nullable enable
namespace OpenQA.Selenium.DevTools
{
/// <summary>
/// The information for each DevTools command
/// </summary>
public class DevToolsCommandData
{
/// <summary>
/// Initializes a new instance of the DevToolsCommandData class.
/// </summary>
/// <param name="commandId">The ID of the commmand execution.</param>
/// <param name="commandName">The method name of the DevTools command.</param>
/// <param name="commandParameters">The parameters of the DevTools command.</param>
/// <exception cref="ArgumentNullException">If <paramref name="commandName"/> is <see langword="null"/>.</exception>
public DevToolsCommandData(long commandId, string commandName, JsonNode commandParameters)
: this(commandId, null, commandName, commandParameters)
{
}
/// <summary>
/// Initializes a new instance of the DevToolsCommandData class.
/// </summary>
/// <param name="commandId">The ID of the commmand execution.</param>
/// <param name="sessionId">The session ID of the current command execution.</param>
/// <param name="commandName">The method name of the DevTools command.</param>
/// <param name="commandParameters">The parameters of the DevTools command.</param>
/// <exception cref="ArgumentNullException">If <paramref name="commandName"/> is <see langword="null"/>.</exception>
public DevToolsCommandData(long commandId, string? sessionId, string commandName, JsonNode commandParameters)
{
CommandId = commandId;
SessionId = sessionId;
CommandName = commandName ?? throw new ArgumentNullException(nameof(commandName));
CommandParameters = commandParameters;
SyncEvent = new ManualResetEventSlim(false);
}
/// <summary>
/// Gets the session ID of the command.
/// </summary>
[JsonPropertyName("sessionId")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? SessionId { get; }
/// <summary>
/// Gets the numeric ID of the command execution.
/// </summary>
[JsonPropertyName("id")]
public long CommandId { get; }
/// <summary>
/// Gets the method name of the command.
/// </summary>
[JsonPropertyName("method")]
public string CommandName { get; }
/// <summary>
/// Gets the parameters for the command.
/// </summary>
[JsonPropertyName("params")]
public JsonNode CommandParameters { get; }
/// <summary>
/// Gets a ManualResetEventSlim on which execution of the command can be synchronized.
/// </summary>
[JsonIgnore]
public ManualResetEventSlim SyncEvent { get; }
/// <summary>
/// Get or sets the result of the command execution.
/// </summary>
[JsonIgnore]
public JsonElement Result { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the command resulted in an error response.
/// </summary>
[JsonIgnore]
public bool IsError { get; set; }
}
}