Esempio n. 1
0
    public async Task JSObjectReference_Dispose_DisallowsFurtherInteropCalls()
    {
        // Arrange
        var jsRuntime = new TestJSRuntime();
        var jsObject  = new JSObjectReference(jsRuntime, 0);

        // Act
        _ = jsObject.DisposeAsync();

        // Assert
        await Assert.ThrowsAsync <ObjectDisposedException>(async() => await jsObject.InvokeAsync <object>("test", "arg1", "arg2"));

        await Assert.ThrowsAsync <ObjectDisposedException>(async() => await jsObject.InvokeAsync <object>("test", CancellationToken.None, "arg1", "arg2"));
    }
Esempio n. 2
0
    public void JSObjectReference_InvokeAsync_CallsUnderlyingJSRuntimeInvokeAsync()
    {
        // Arrange
        var jsRuntime = new TestJSRuntime();
        var jsObject  = new JSObjectReference(jsRuntime, 0);

        // Act
        _ = jsObject.InvokeAsync <object>("test", "arg1", "arg2");

        // Assert
        Assert.Equal(1, jsRuntime.BeginInvokeJSInvocationCount);
    }
Esempio n. 3
0
 /// <summary>
 /// Gets the maximum zoom level on which the bounds fit the map view.
 /// </summary>
 /// <param name="bounds">The <see cref="LatLngBounds"/> to fit to the map.</param>
 /// <param name="inside">A flag indicating the fit direction. If true, method returns minimum zoom level
 /// on which the map fits into the bounds.</param>
 /// <param name="padding">The padding in pixels.</param>
 /// <returns></returns>
 public async Task <int> GetBoundsZoom(LatLngBounds bounds, bool inside = false, Point padding = null)
 {
     if (bounds.JSBinder is null)
     {
         await bounds.BindJsObjectReference(this.JSBinder);
     }
     bounds.GuardAgainstNullBinding("Cannot get bounds zoom. No JavaScript binding has been set up for the bounds parameter.");
     if (padding is not null)
     {
         if (padding.JSBinder is null)
         {
             await padding.BindJsObjectReference(this.JSBinder);
         }
         padding.GuardAgainstNullBinding("Cannot get bounds zoom. No JavaScript binding has been set up for the padding parameter.");
     }
     return(await JSObjectReference.InvokeAsync <int>("getBoundsZoom", bounds.JSObjectReference, inside, padding?.JSObjectReference));
 }
Esempio n. 4
0
 /// <summary>
 /// Gets the geographical bounds of the map view.
 /// </summary>
 /// <returns>A <see cref="LatLngBounds"/> object representing the geographical bounds of the map.</returns>
 public async Task <LatLngBounds> GetBounds()
 {
     return(await JSObjectReference.InvokeAsync <LatLngBounds>("getBounds"));
 }
Esempio n. 5
0
 /// <summary>
 /// Gets the maximum zoom level of the map view.
 /// </summary>
 /// <returns>The maximum zoom level.</returns>
 public async Task <int> GetMaxZoom()
 {
     return(await JSObjectReference.InvokeAsync <int>("getMaxZoom"));
 }
Esempio n. 6
0
 /// <summary>
 /// Gets the point at the centre of the map view.
 /// </summary>
 /// <returns>A <see cref="LatLng"/> representing the geographical centre of the map.</returns>
 public async Task <LatLng> GetCenter()
 {
     return(await JSObjectReference.InvokeAsync <LatLng>("getCenter"));
 }
Esempio n. 7
0
 /// <summary>
 /// Gets the world's bounds in pixel coordinates.
 /// </summary>
 /// <param name="zoom">The zoom level used to calculate the bounds. Current map zoom level is used if null or omitted.</param>
 /// <returns>A <see cref="Bounds"/> representing the size of the map container in pixels.</returns>
 public async Task <Bounds> GetPixelWorldBounds(int?zoom = null)
 {
     return(await JSObjectReference.InvokeAsync <Bounds>("getPixelWorldBounds", zoom));
 }
Esempio n. 8
0
 /// <summary>
 /// Gets the projected pixel coordinates of the top left point of the map layer.
 /// </summary>
 /// <returns>A <see cref="Point"/> representing top left point of the map in pixels.</returns>
 public async Task <Point> GetPixelOrigin()
 {
     return(await JSObjectReference.InvokeAsync <Point>("getPixelOrigin"));
 }
Esempio n. 9
0
 /// <summary>
 /// Gets the bounds of the map view in projected pixel coordinates.
 /// </summary>
 /// <returns>A <see cref="Bounds"/> representing the size of the map container in pixels.</returns>
 public async Task <Bounds> GetPixelBounds()
 {
     return(await JSObjectReference.InvokeAsync <Bounds>("getPixelBounds"));
 }
Esempio n. 10
0
 /// <summary>
 /// Gets the size of the map container in pixels.
 /// </summary>
 /// <returns>A <see cref="Point"/> representing the size of the map container in pixels.</returns>
 public async Task <Point> GetSize()
 {
     return(await JSObjectReference.InvokeAsync <Point>("getSize"));
 }