@@ -27,61 +27,59 @@ namespace OpenQA.Selenium.BiDi.Browser;
2727
2828public sealed class BrowserModule : Module
2929{
30- private BrowserModuleJsonSerializerContext _jsonContext = null ! ;
31-
3230 public async Task < EmptyResult > CloseAsync ( CloseOptions ? options = null )
3331 {
34- return await Broker . ExecuteCommandAsync < CloseCommand , EmptyResult > ( new CloseCommand ( ) , options , _jsonContext ) . ConfigureAwait ( false ) ;
32+ return await Broker . ExecuteCommandAsync < CloseCommand , EmptyResult > ( new CloseCommand ( ) , options , JsonContext ) . ConfigureAwait ( false ) ;
3533 }
3634
3735 public async Task < UserContextInfo > CreateUserContextAsync ( CreateUserContextOptions ? options = null )
3836 {
3937 var @params = new CreateUserContextParameters ( options ? . AcceptInsecureCerts , options ? . Proxy , options ? . UnhandledPromptBehavior ) ;
4038
41- return await Broker . ExecuteCommandAsync < CreateUserContextCommand , UserContextInfo > ( new CreateUserContextCommand ( @params ) , options , _jsonContext ) . ConfigureAwait ( false ) ;
39+ return await Broker . ExecuteCommandAsync < CreateUserContextCommand , UserContextInfo > ( new CreateUserContextCommand ( @params ) , options , JsonContext ) . ConfigureAwait ( false ) ;
4240 }
4341
4442 public async Task < GetUserContextsResult > GetUserContextsAsync ( GetUserContextsOptions ? options = null )
4543 {
46- return await Broker . ExecuteCommandAsync < GetUserContextsCommand , GetUserContextsResult > ( new GetUserContextsCommand ( ) , options , _jsonContext ) . ConfigureAwait ( false ) ;
44+ return await Broker . ExecuteCommandAsync < GetUserContextsCommand , GetUserContextsResult > ( new GetUserContextsCommand ( ) , options , JsonContext ) . ConfigureAwait ( false ) ;
4745 }
4846
4947 public async Task < EmptyResult > RemoveUserContextAsync ( UserContext userContext , RemoveUserContextOptions ? options = null )
5048 {
5149 var @params = new RemoveUserContextParameters ( userContext ) ;
5250
53- return await Broker . ExecuteCommandAsync < RemoveUserContextCommand , EmptyResult > ( new RemoveUserContextCommand ( @params ) , options , _jsonContext ) . ConfigureAwait ( false ) ;
51+ return await Broker . ExecuteCommandAsync < RemoveUserContextCommand , EmptyResult > ( new RemoveUserContextCommand ( @params ) , options , JsonContext ) . ConfigureAwait ( false ) ;
5452 }
5553
5654 public async Task < GetClientWindowsResult > GetClientWindowsAsync ( GetClientWindowsOptions ? options = null )
5755 {
58- return await Broker . ExecuteCommandAsync < GetClientWindowsCommand , GetClientWindowsResult > ( new ( ) , options , _jsonContext ) . ConfigureAwait ( false ) ;
56+ return await Broker . ExecuteCommandAsync < GetClientWindowsCommand , GetClientWindowsResult > ( new ( ) , options , JsonContext ) . ConfigureAwait ( false ) ;
5957 }
6058
6159 public async Task < EmptyResult > SetDownloadBehaviorAllowedAsync ( string destinationFolder , SetDownloadBehaviorOptions ? options = null )
6260 {
6361 var @params = new SetDownloadBehaviorParameters ( new DownloadBehaviorAllowed ( destinationFolder ) , options ? . UserContexts ) ;
6462
65- return await Broker . ExecuteCommandAsync < SetDownloadBehaviorCommand , EmptyResult > ( new SetDownloadBehaviorCommand ( @params ) , options , _jsonContext ) . ConfigureAwait ( false ) ;
63+ return await Broker . ExecuteCommandAsync < SetDownloadBehaviorCommand , EmptyResult > ( new SetDownloadBehaviorCommand ( @params ) , options , JsonContext ) . ConfigureAwait ( false ) ;
6664 }
6765
6866 public async Task < EmptyResult > SetDownloadBehaviorAllowedAsync ( SetDownloadBehaviorOptions ? options = null )
6967 {
7068 var @params = new SetDownloadBehaviorParameters ( null , options ? . UserContexts ) ;
7169
72- return await Broker . ExecuteCommandAsync < SetDownloadBehaviorCommand , EmptyResult > ( new SetDownloadBehaviorCommand ( @params ) , options , _jsonContext ) . ConfigureAwait ( false ) ;
70+ return await Broker . ExecuteCommandAsync < SetDownloadBehaviorCommand , EmptyResult > ( new SetDownloadBehaviorCommand ( @params ) , options , JsonContext ) . ConfigureAwait ( false ) ;
7371 }
7472
7573 public async Task < EmptyResult > SetDownloadBehaviorDeniedAsync ( SetDownloadBehaviorOptions ? options = null )
7674 {
7775 var @params = new SetDownloadBehaviorParameters ( new DownloadBehaviorDenied ( ) , options ? . UserContexts ) ;
7876
79- return await Broker . ExecuteCommandAsync < SetDownloadBehaviorCommand , EmptyResult > ( new SetDownloadBehaviorCommand ( @params ) , options , _jsonContext ) . ConfigureAwait ( false ) ;
77+ return await Broker . ExecuteCommandAsync < SetDownloadBehaviorCommand , EmptyResult > ( new SetDownloadBehaviorCommand ( @params ) , options , JsonContext ) . ConfigureAwait ( false ) ;
8078 }
8179
82- protected internal override void Initialize ( JsonSerializerOptions options )
80+ protected internal override JsonSerializerContext ConfigureJson ( JsonSerializerOptions options )
8381 {
84- _jsonContext = new ( options ) ;
82+ return new BrowserModuleJsonSerializerContext ( options ) ;
8583 }
8684}
8785
0 commit comments