diff --git a/dotnet/src/webdriver/BiDi/BiDi.cs b/dotnet/src/webdriver/BiDi/BiDi.cs index b80652d52bd20..448e0ea85bf48 100644 --- a/dotnet/src/webdriver/BiDi/BiDi.cs +++ b/dotnet/src/webdriver/BiDi/BiDi.cs @@ -18,7 +18,6 @@ // using System; -using System.Collections.Concurrent; using System.Text.Json; using System.Text.Json.Serialization; using System.Threading; @@ -35,8 +34,6 @@ public sealed class BiDi : IAsyncDisposable private readonly JsonSerializerOptions _jsonOptions; private readonly BiDiJsonSerializerContext _jsonContext; - private readonly ConcurrentDictionary _modules = []; - private BiDi(string url) { var uri = new Uri(url); @@ -68,32 +65,37 @@ private BiDi(string url) _jsonContext = new BiDiJsonSerializerContext(_jsonOptions); _broker = new Broker(this, uri, _jsonOptions); + SessionModule = Module.Create(this, _broker, _jsonOptions, _jsonContext); + BrowsingContext = Module.Create(this, _broker, _jsonOptions, _jsonContext); + Browser = Module.Create(this, _broker, _jsonOptions, _jsonContext); + Network = Module.Create(this, _broker, _jsonOptions, _jsonContext); + InputModule = Module.Create(this, _broker, _jsonOptions, _jsonContext); + Script = Module.Create(this, _broker, _jsonOptions, _jsonContext); + Log = Module.Create(this, _broker, _jsonOptions, _jsonContext); + Storage = Module.Create(this, _broker, _jsonOptions, _jsonContext); + WebExtension = Module.Create(this, _broker, _jsonOptions, _jsonContext); + Emulation = Module.Create(this, _broker, _jsonOptions, _jsonContext); } - internal Session.SessionModule SessionModule => AsModule(); - - public BrowsingContext.BrowsingContextModule BrowsingContext => AsModule(); + internal Session.SessionModule SessionModule { get; } - public Browser.BrowserModule Browser => AsModule(); + public BrowsingContext.BrowsingContextModule BrowsingContext { get; } - public Network.NetworkModule Network => AsModule(); + public Browser.BrowserModule Browser { get; } - internal Input.InputModule InputModule => AsModule(); + public Network.NetworkModule Network { get; } - public Script.ScriptModule Script => AsModule(); + internal Input.InputModule InputModule { get; } - public Log.LogModule Log => AsModule(); + public Script.ScriptModule Script { get; } - public Storage.StorageModule Storage => AsModule(); + public Log.LogModule Log { get; } - public WebExtension.WebExtensionModule WebExtension => AsModule(); + public Storage.StorageModule Storage { get; } - public Emulation.EmulationModule Emulation => AsModule(); + public WebExtension.WebExtensionModule WebExtension { get; } - public TModule AsModule() where TModule : Module, new() - { - return (TModule)_modules.GetOrAdd(typeof(TModule), _ => Module.Create(this, _broker, _jsonOptions, _jsonContext)); - } + public Emulation.EmulationModule Emulation { get; } public Task StatusAsync() {