@@ -105,22 +105,20 @@ public async Task<SetScrollbarTypeOverrideResult> SetScrollbarTypeOverrideAsync(
105105 return await ExecuteAsync ( SetScrollbarTypeOverrideCommand , @params , options , cancellationToken ) . ConfigureAwait ( false ) ;
106106 }
107107
108- public async Task < SetGeolocationOverrideResult > SetGeolocationCoordinatesOverrideAsync ( double latitude , double longitude , SetGeolocationCoordinatesOverrideOptions ? options = null , CancellationToken cancellationToken = default )
108+ public async Task < SetGeolocationOverrideResult > SetGeolocationOverrideAsync ( GeolocationOverride ? geolocationOverride , SetGeolocationOverrideOptions ? options = null , CancellationToken cancellationToken = default )
109109 {
110- var coordinates = new GeolocationCoordinates ( latitude , longitude , options ? . Accuracy , options ? . Altitude , options ? . AltitudeAccuracy , options ? . Heading , options ? . Speed ) ;
111- var @params = new SetGeolocationOverrideCoordinatesParameters ( coordinates , options ? . Contexts , options ? . UserContexts ) ;
112- return await ExecuteAsync ( SetGeolocationOverrideCommand , @params , options , cancellationToken ) . ConfigureAwait ( false ) ;
113- }
110+ SetGeolocationOverrideParameters @params = geolocationOverride switch
111+ {
112+ GeolocationCoordinatesOverride c => new SetGeolocationOverrideCoordinatesParameters (
113+ new GeolocationCoordinates ( c . Latitude , c . Longitude , c . Accuracy , c . Altitude , c . AltitudeAccuracy , c . Heading , c . Speed ) ,
114+ options ? . Contexts , options ? . UserContexts ) ,
115+ GeolocationPositionErrorOverride => new SetGeolocationOverridePositionErrorParameters (
116+ new GeolocationPositionError ( ) , options ? . Contexts , options ? . UserContexts ) ,
117+ null => new SetGeolocationOverrideCoordinatesParameters (
118+ null , options ? . Contexts , options ? . UserContexts ) ,
119+ _ => throw new ArgumentException ( $ "Unknown geolocation override type: { geolocationOverride . GetType ( ) } ", nameof ( geolocationOverride ) )
120+ } ;
114121
115- public async Task < SetGeolocationOverrideResult > SetGeolocationCoordinatesOverrideAsync ( SetGeolocationOverrideOptions ? options = null , CancellationToken cancellationToken = default )
116- {
117- var @params = new SetGeolocationOverrideCoordinatesParameters ( null , options ? . Contexts , options ? . UserContexts ) ;
118- return await ExecuteAsync ( SetGeolocationOverrideCommand , @params , options , cancellationToken ) . ConfigureAwait ( false ) ;
119- }
120-
121- public async Task < SetGeolocationOverrideResult > SetGeolocationPositionErrorOverrideAsync ( SetGeolocationPositionErrorOverrideOptions ? options = null , CancellationToken cancellationToken = default )
122- {
123- var @params = new SetGeolocationOverridePositionErrorParameters ( new GeolocationPositionError ( ) , options ? . Contexts , options ? . UserContexts ) ;
124122 return await ExecuteAsync ( SetGeolocationOverrideCommand , @params , options , cancellationToken ) . ConfigureAwait ( false ) ;
125123 }
126124
0 commit comments