22
22
using System . IO ;
23
23
using System . Text ;
24
24
25
+ #nullable enable
26
+
25
27
namespace OpenQA . Selenium . IE
26
28
{
27
29
/// <summary>
28
- /// Exposes the service provided by the native IEDriverServer executable.
30
+ /// Exposes the service provided by the native <c> IEDriverServer</c> executable.
29
31
/// </summary>
30
32
public sealed class InternetExplorerDriverService : DriverService
31
33
{
32
34
private const string InternetExplorerDriverServiceFileName = "IEDriverServer.exe" ;
33
35
34
- private InternetExplorerDriverLogLevel loggingLevel = InternetExplorerDriverLogLevel . Fatal ;
35
- private string host = string . Empty ;
36
- private string logFile = string . Empty ;
37
- private string libraryExtractionPath = string . Empty ;
38
- private string whitelistedIpAddresses = string . Empty ;
39
-
40
36
/// <summary>
41
37
/// Initializes a new instance of the <see cref="InternetExplorerDriverService"/> class.
42
38
/// </summary>
43
- /// <param name="executablePath">The full path to the IEDriverServer executable.</param>
44
- /// <param name="executableFileName">The file name of the IEDriverServer executable.</param>
45
- /// <param name="port">The port on which the IEDriverServer executable should listen.</param>
46
- private InternetExplorerDriverService ( string executablePath , string executableFileName , int port )
39
+ /// <param name="executablePath">The full path to the <c> IEDriverServer</c> executable.</param>
40
+ /// <param name="executableFileName">The file name of the <c> IEDriverServer</c> executable.</param>
41
+ /// <param name="port">The port on which the <c> IEDriverServer</c> executable should listen.</param>
42
+ private InternetExplorerDriverService ( string ? executablePath , string ? executableFileName , int port )
47
43
: base ( executablePath , port , executableFileName )
48
44
{
49
45
}
@@ -55,57 +51,36 @@ protected override DriverOptions GetDefaultDriverOptions()
55
51
}
56
52
57
53
/// <summary>
58
- /// Gets or sets the value of the host adapter on which the IEDriverServer should listen for connections.
54
+ /// Gets or sets the value of the host adapter on which the <c> IEDriverServer</c> should listen for connections.
59
55
/// </summary>
60
- public string Host
61
- {
62
- get { return this . host ; }
63
- set { this . host = value ; }
64
- }
56
+ public string ? Host { get ; set ; }
65
57
66
58
/// <summary>
67
- /// Gets or sets the location of the log file written to by the IEDriverServer.
59
+ /// Gets or sets the location of the log file written to by the <c> IEDriverServer</c> .
68
60
/// </summary>
69
- public string LogFile
70
- {
71
- get { return this . logFile ; }
72
- set { this . logFile = value ; }
73
- }
61
+ public string ? LogFile { get ; set ; }
74
62
75
63
/// <summary>
76
- /// Gets or sets the logging level used by the IEDriverServer.
64
+ /// Gets or sets the logging level used by the <c> IEDriverServer</c>. Defaults to <see cref="InternetExplorerDriverLogLevel.Fatal"/> .
77
65
/// </summary>
78
- public InternetExplorerDriverLogLevel LoggingLevel
79
- {
80
- get { return this . loggingLevel ; }
81
- set { this . loggingLevel = value ; }
82
- }
66
+ public InternetExplorerDriverLogLevel LoggingLevel { get ; set ; } = InternetExplorerDriverLogLevel . Fatal ;
83
67
84
68
/// <summary>
85
- /// Gets or sets the path to which the supporting library of the IEDriverServer.exe is extracted.
86
- /// Defaults to the temp directory if this property is not set .
69
+ /// Gets or sets the path to which the supporting library of the <c> IEDriverServer.exe</c> is extracted.
70
+ /// Defaults to the temp directory if this property is <see langword="null"/> or <see cref="string.Empty"/> .
87
71
/// </summary>
88
72
/// <remarks>
89
- /// The IEDriverServer.exe requires extraction of a supporting library to perform some of its functions. Setting
73
+ /// The <c> IEDriverServer.exe</c> requires extraction of a supporting library to perform some of its functions. Setting
90
74
/// This library is extracted to the temp directory if this property is not set. If the property is set, it must
91
75
/// be set to a valid directory.
92
76
/// </remarks>
93
- public string LibraryExtractionPath
94
- {
95
- get { return this . libraryExtractionPath ; }
96
- set { this . libraryExtractionPath = value ; }
97
- }
77
+ public string ? LibraryExtractionPath { get ; set ; }
98
78
99
79
/// <summary>
100
- /// Gets or sets the comma-delimited list of IP addresses that are approved to
101
- /// connect to this instance of the IEDriverServer. Defaults to an empty string,
102
- /// which means only the local loopback address can connect.
80
+ /// <para>Gets or sets the comma-delimited list of IP addresses that are approved to connect to this instance of the <c>IEDriverServer</c>.</para>
81
+ /// <para>If <see langword="null"/> or <see cref="string.Empty"/>, only the local loopback address can connect.</para>
103
82
/// </summary>
104
- public string WhitelistedIPAddresses
105
- {
106
- get { return this . whitelistedIpAddresses ; }
107
- set { this . whitelistedIpAddresses = value ; }
108
- }
83
+ public string ? WhitelistedIPAddresses { get ; set ; }
109
84
110
85
/// <summary>
111
86
/// Gets the command-line arguments for the driver service.
@@ -115,29 +90,29 @@ protected override string CommandLineArguments
115
90
get
116
91
{
117
92
StringBuilder argsBuilder = new StringBuilder ( base . CommandLineArguments ) ;
118
- if ( ! string . IsNullOrEmpty ( this . host ) )
93
+ if ( ! string . IsNullOrEmpty ( this . Host ) )
119
94
{
120
- argsBuilder . Append ( string . Format ( CultureInfo . InvariantCulture , " -host={0}" , this . host ) ) ;
95
+ argsBuilder . Append ( string . Format ( CultureInfo . InvariantCulture , " -host={0}" , this . Host ) ) ;
121
96
}
122
97
123
- if ( ! string . IsNullOrEmpty ( this . logFile ) )
98
+ if ( ! string . IsNullOrEmpty ( this . LogFile ) )
124
99
{
125
- argsBuilder . Append ( string . Format ( CultureInfo . InvariantCulture , " -log-file=\" {0}\" " , this . logFile ) ) ;
100
+ argsBuilder . Append ( string . Format ( CultureInfo . InvariantCulture , " -log-file=\" {0}\" " , this . LogFile ) ) ;
126
101
}
127
102
128
- if ( ! string . IsNullOrEmpty ( this . libraryExtractionPath ) )
103
+ if ( ! string . IsNullOrEmpty ( this . LibraryExtractionPath ) )
129
104
{
130
- argsBuilder . Append ( string . Format ( CultureInfo . InvariantCulture , " -extract-path=\" {0}\" " , this . libraryExtractionPath ) ) ;
105
+ argsBuilder . Append ( string . Format ( CultureInfo . InvariantCulture , " -extract-path=\" {0}\" " , this . LibraryExtractionPath ) ) ;
131
106
}
132
107
133
- if ( this . loggingLevel != InternetExplorerDriverLogLevel . Fatal )
108
+ if ( this . LoggingLevel != InternetExplorerDriverLogLevel . Fatal )
134
109
{
135
- argsBuilder . Append ( string . Format ( CultureInfo . InvariantCulture , " -log-level={0}" , this . loggingLevel . ToString ( ) . ToUpperInvariant ( ) ) ) ;
110
+ argsBuilder . Append ( string . Format ( CultureInfo . InvariantCulture , " -log-level={0}" , this . LoggingLevel . ToString ( ) . ToUpperInvariant ( ) ) ) ;
136
111
}
137
112
138
- if ( ! string . IsNullOrEmpty ( this . whitelistedIpAddresses ) )
113
+ if ( ! string . IsNullOrEmpty ( this . WhitelistedIPAddresses ) )
139
114
{
140
- argsBuilder . Append ( string . Format ( CultureInfo . InvariantCulture , " -whitelisted-ips={0}" , this . whitelistedIpAddresses ) ) ;
115
+ argsBuilder . Append ( string . Format ( CultureInfo . InvariantCulture , " -whitelisted-ips={0}" , this . WhitelistedIPAddresses ) ) ;
141
116
}
142
117
143
118
if ( this . SuppressInitialDiagnosticInformation )
@@ -159,17 +134,17 @@ public static InternetExplorerDriverService CreateDefaultService()
159
134
}
160
135
161
136
/// <summary>
162
- /// Creates a default instance of the InternetExplorerDriverService using a specified path to the IEDriverServer executable.
137
+ /// Creates a default instance of the InternetExplorerDriverService using a specified path to the <c> IEDriverServer</c> executable.
163
138
/// </summary>
164
- /// <param name="driverPath">The path to the executable or the directory containing the IEDriverServer executable.</param>
139
+ /// <param name="driverPath">The path to the executable or the directory containing the <c> IEDriverServer</c> executable.</param>
165
140
/// <returns>A InternetExplorerDriverService using a random port.</returns>
166
141
public static InternetExplorerDriverService CreateDefaultService ( string driverPath )
167
142
{
168
143
string fileName ;
169
144
if ( File . Exists ( driverPath ) )
170
145
{
171
146
fileName = Path . GetFileName ( driverPath ) ;
172
- driverPath = Path . GetDirectoryName ( driverPath ) ;
147
+ driverPath = Path . GetDirectoryName ( driverPath ) ! ;
173
148
}
174
149
else
175
150
{
@@ -180,10 +155,10 @@ public static InternetExplorerDriverService CreateDefaultService(string driverPa
180
155
}
181
156
182
157
/// <summary>
183
- /// Creates a default instance of the InternetExplorerDriverService using a specified path to the IEDriverServer executable with the given name.
158
+ /// Creates a default instance of the InternetExplorerDriverService using a specified path to the <c> IEDriverServer</c> executable with the given name.
184
159
/// </summary>
185
- /// <param name="driverPath">The directory containing the IEDriverServer executable.</param>
186
- /// <param name="driverExecutableFileName">The name of the IEDriverServer executable file.</param>
160
+ /// <param name="driverPath">The directory containing the <c> IEDriverServer</c> executable.</param>
161
+ /// <param name="driverExecutableFileName">The name of the <c> IEDriverServer</c> executable file.</param>
187
162
/// <returns>A InternetExplorerDriverService using a random port.</returns>
188
163
public static InternetExplorerDriverService CreateDefaultService ( string driverPath , string driverExecutableFileName )
189
164
{
0 commit comments