1818// </copyright>
1919
2020using System ;
21- using System . Collections . Concurrent ;
2221using System . Text . Json ;
2322using System . Text . Json . Serialization ;
2423using System . Threading ;
@@ -35,8 +34,6 @@ public sealed class BiDi : IAsyncDisposable
3534 private readonly JsonSerializerOptions _jsonOptions ;
3635 private readonly BiDiJsonSerializerContext _jsonContext ;
3736
38- private readonly ConcurrentDictionary < Type , Module > _modules = [ ] ;
39-
4037 private BiDi ( string url )
4138 {
4239 var uri = new Uri ( url ) ;
@@ -68,32 +65,37 @@ private BiDi(string url)
6865 _jsonContext = new BiDiJsonSerializerContext ( _jsonOptions ) ;
6966
7067 _broker = new Broker ( this , uri , _jsonOptions ) ;
68+ SessionModule = Module . Create < Session . SessionModule > ( this , _broker , _jsonOptions , _jsonContext ) ;
69+ BrowsingContext = Module . Create < BrowsingContext . BrowsingContextModule > ( this , _broker , _jsonOptions , _jsonContext ) ;
70+ Browser = Module . Create < Browser . BrowserModule > ( this , _broker , _jsonOptions , _jsonContext ) ;
71+ Network = Module . Create < Network . NetworkModule > ( this , _broker , _jsonOptions , _jsonContext ) ;
72+ InputModule = Module . Create < Input . InputModule > ( this , _broker , _jsonOptions , _jsonContext ) ;
73+ Script = Module . Create < Script . ScriptModule > ( this , _broker , _jsonOptions , _jsonContext ) ;
74+ Log = Module . Create < Log . LogModule > ( this , _broker , _jsonOptions , _jsonContext ) ;
75+ Storage = Module . Create < Storage . StorageModule > ( this , _broker , _jsonOptions , _jsonContext ) ;
76+ WebExtension = Module . Create < WebExtension . WebExtensionModule > ( this , _broker , _jsonOptions , _jsonContext ) ;
77+ Emulation = Module . Create < Emulation . EmulationModule > ( this , _broker , _jsonOptions , _jsonContext ) ;
7178 }
7279
73- internal Session . SessionModule SessionModule => AsModule < Session . SessionModule > ( ) ;
74-
75- public BrowsingContext . BrowsingContextModule BrowsingContext => AsModule < BrowsingContext . BrowsingContextModule > ( ) ;
80+ internal Session . SessionModule SessionModule { get ; }
7681
77- public Browser . BrowserModule Browser => AsModule < Browser . BrowserModule > ( ) ;
82+ public BrowsingContext . BrowsingContextModule BrowsingContext { get ; }
7883
79- public Network . NetworkModule Network => AsModule < Network . NetworkModule > ( ) ;
84+ public Browser . BrowserModule Browser { get ; }
8085
81- internal Input . InputModule InputModule => AsModule < Input . InputModule > ( ) ;
86+ public Network . NetworkModule Network { get ; }
8287
83- public Script . ScriptModule Script => AsModule < Script . ScriptModule > ( ) ;
88+ internal Input . InputModule InputModule { get ; }
8489
85- public Log . LogModule Log => AsModule < Log . LogModule > ( ) ;
90+ public Script . ScriptModule Script { get ; }
8691
87- public Storage . StorageModule Storage => AsModule < Storage . StorageModule > ( ) ;
92+ public Log . LogModule Log { get ; }
8893
89- public WebExtension . WebExtensionModule WebExtension => AsModule < WebExtension . WebExtensionModule > ( ) ;
94+ public Storage . StorageModule Storage { get ; }
9095
91- public Emulation . EmulationModule Emulation => AsModule < Emulation . EmulationModule > ( ) ;
96+ public WebExtension . WebExtensionModule WebExtension { get ; }
9297
93- public TModule AsModule < TModule > ( ) where TModule : Module , new ( )
94- {
95- return ( TModule ) _modules . GetOrAdd ( typeof ( TModule ) , _ => Module . Create < TModule > ( this , _broker , _jsonOptions , _jsonContext ) ) ;
96- }
98+ public Emulation . EmulationModule Emulation { get ; }
9799
98100 public Task < Session . StatusResult > StatusAsync ( )
99101 {
0 commit comments