18
18
// </copyright>
19
19
20
20
using System ;
21
- using System . Collections . Concurrent ;
22
21
using System . Text . Json ;
23
22
using System . Text . Json . Serialization ;
24
23
using System . Threading ;
@@ -35,8 +34,6 @@ public sealed class BiDi : IAsyncDisposable
35
34
private readonly JsonSerializerOptions _jsonOptions ;
36
35
private readonly BiDiJsonSerializerContext _jsonContext ;
37
36
38
- private readonly ConcurrentDictionary < Type , Module > _modules = [ ] ;
39
-
40
37
private BiDi ( string url )
41
38
{
42
39
var uri = new Uri ( url ) ;
@@ -68,32 +65,37 @@ private BiDi(string url)
68
65
_jsonContext = new BiDiJsonSerializerContext ( _jsonOptions ) ;
69
66
70
67
_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 ) ;
71
78
}
72
79
73
- internal Session . SessionModule SessionModule => AsModule < Session . SessionModule > ( ) ;
74
-
75
- public BrowsingContext . BrowsingContextModule BrowsingContext => AsModule < BrowsingContext . BrowsingContextModule > ( ) ;
80
+ internal Session . SessionModule SessionModule { get ; }
76
81
77
- public Browser . BrowserModule Browser => AsModule < Browser . BrowserModule > ( ) ;
82
+ public BrowsingContext . BrowsingContextModule BrowsingContext { get ; }
78
83
79
- public Network . NetworkModule Network => AsModule < Network . NetworkModule > ( ) ;
84
+ public Browser . BrowserModule Browser { get ; }
80
85
81
- internal Input . InputModule InputModule => AsModule < Input . InputModule > ( ) ;
86
+ public Network . NetworkModule Network { get ; }
82
87
83
- public Script . ScriptModule Script => AsModule < Script . ScriptModule > ( ) ;
88
+ internal Input . InputModule InputModule { get ; }
84
89
85
- public Log . LogModule Log => AsModule < Log . LogModule > ( ) ;
90
+ public Script . ScriptModule Script { get ; }
86
91
87
- public Storage . StorageModule Storage => AsModule < Storage . StorageModule > ( ) ;
92
+ public Log . LogModule Log { get ; }
88
93
89
- public WebExtension . WebExtensionModule WebExtension => AsModule < WebExtension . WebExtensionModule > ( ) ;
94
+ public Storage . StorageModule Storage { get ; }
90
95
91
- public Emulation . EmulationModule Emulation => AsModule < Emulation . EmulationModule > ( ) ;
96
+ public WebExtension . WebExtensionModule WebExtension { get ; }
92
97
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 ; }
97
99
98
100
public Task < Session . StatusResult > StatusAsync ( )
99
101
{
0 commit comments