Skip to content

Commit cf3f8c8

Browse files
committed
[dotnet] Replace Lazy<T> with ??= in BrowsingContext
1 parent 2570c3d commit cf3f8c8

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContext.cs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,39 +29,33 @@ internal BrowsingContext(BiDi bidi, string id)
2929
{
3030
BiDi = bidi;
3131
Id = id;
32-
33-
_logModule = new Lazy<BrowsingContextLogModule>(() => new BrowsingContextLogModule(this, BiDi.Log));
34-
_networkModule = new Lazy<BrowsingContextNetworkModule>(() => new BrowsingContextNetworkModule(this, BiDi.Network));
35-
_scriptModule = new Lazy<BrowsingContextScriptModule>(() => new BrowsingContextScriptModule(this, BiDi.Script));
36-
_storageModule = new Lazy<BrowsingContextStorageModule>(() => new BrowsingContextStorageModule(this, BiDi.Storage));
37-
_inputModule = new Lazy<BrowsingContextInputModule>(() => new BrowsingContextInputModule(this, BiDi.InputModule));
3832
}
3933

40-
private readonly Lazy<BrowsingContextLogModule> _logModule;
41-
private readonly Lazy<BrowsingContextNetworkModule> _networkModule;
42-
private readonly Lazy<BrowsingContextScriptModule> _scriptModule;
43-
private readonly Lazy<BrowsingContextStorageModule> _storageModule;
44-
private readonly Lazy<BrowsingContextInputModule> _inputModule;
34+
private BrowsingContextLogModule? _logModule;
35+
private BrowsingContextNetworkModule? _networkModule;
36+
private BrowsingContextScriptModule? _scriptModule;
37+
private BrowsingContextStorageModule? _storageModule;
38+
private BrowsingContextInputModule? _inputModule;
4539

4640
internal string Id { get; }
4741

4842
[JsonIgnore]
4943
public BiDi BiDi { get; }
5044

5145
[JsonIgnore]
52-
public BrowsingContextLogModule Log => _logModule.Value;
46+
public BrowsingContextLogModule Log => _logModule ??= new BrowsingContextLogModule(this, BiDi.Log);
5347

5448
[JsonIgnore]
55-
public BrowsingContextNetworkModule Network => _networkModule.Value;
49+
public BrowsingContextNetworkModule Network => _networkModule ??= new BrowsingContextNetworkModule(this, BiDi.Network);
5650

5751
[JsonIgnore]
58-
public BrowsingContextScriptModule Script => _scriptModule.Value;
52+
public BrowsingContextScriptModule Script => _scriptModule ??= new BrowsingContextScriptModule(this, BiDi.Script);
5953

6054
[JsonIgnore]
61-
public BrowsingContextStorageModule Storage => _storageModule.Value;
55+
public BrowsingContextStorageModule Storage => _storageModule ??= new BrowsingContextStorageModule(this, BiDi.Storage);
6256

6357
[JsonIgnore]
64-
public BrowsingContextInputModule Input => _inputModule.Value;
58+
public BrowsingContextInputModule Input => _inputModule ??= new BrowsingContextInputModule(this, BiDi.InputModule);
6559

6660
public Task<NavigateResult> NavigateAsync(string url, NavigateOptions? options = null)
6761
{

0 commit comments

Comments
 (0)