From 6213455bb3dcd2bb486e1f592bf4d79cdacf01b2 Mon Sep 17 00:00:00 2001 From: Luke Latham <1622880+guardrex@users.noreply.github.com> Date: Tue, 1 Nov 2022 06:40:28 -0500 Subject: [PATCH 1/2] Delete 7.0 unmarshalled interop example --- .../call-js-from-dotnet/CallJsExample10.razor | 80 ------------------- 1 file changed, 80 deletions(-) delete mode 100644 7.0/BlazorSample_WebAssembly/Pages/call-js-from-dotnet/CallJsExample10.razor diff --git a/7.0/BlazorSample_WebAssembly/Pages/call-js-from-dotnet/CallJsExample10.razor b/7.0/BlazorSample_WebAssembly/Pages/call-js-from-dotnet/CallJsExample10.razor deleted file mode 100644 index 442e893f2..000000000 --- a/7.0/BlazorSample_WebAssembly/Pages/call-js-from-dotnet/CallJsExample10.razor +++ /dev/null @@ -1,80 +0,0 @@ -@page "/call-js-example-10" -@using System.Runtime.InteropServices -@using Microsoft.JSInterop -@inject IJSRuntime JS - -

Call JS Example 10

- -@if (callResultForBoolean) -{ -

JS interop was successful!

-} - -@if (!string.IsNullOrEmpty(callResultForString)) -{ -

@callResultForString

-} - -

- - -

- -

- Doctor Who - is a registered trademark of the BBC. -

- -@code { - private bool callResultForBoolean; - private string? callResultForString; - - private void CallJSUnmarshalledForBoolean() - { - var unmarshalledRuntime = (IJSUnmarshalledRuntime)JS; - - var jsUnmarshalledReference = unmarshalledRuntime - .InvokeUnmarshalled( - "returnObjectReference"); - - callResultForBoolean = - jsUnmarshalledReference.InvokeUnmarshalled( - "unmarshalledFunctionReturnBoolean", GetStruct()); - } - - private void CallJSUnmarshalledForString() - { - var unmarshalledRuntime = (IJSUnmarshalledRuntime)JS; - - var jsUnmarshalledReference = unmarshalledRuntime - .InvokeUnmarshalled( - "returnObjectReference"); - - callResultForString = - jsUnmarshalledReference.InvokeUnmarshalled( - "unmarshalledFunctionReturnString", GetStruct()); - } - - private InteropStruct GetStruct() - { - return new InteropStruct - { - Name = "Brigadier Alistair Gordon Lethbridge-Stewart", - Year = 1968, - }; - } - - [StructLayout(LayoutKind.Explicit)] - public struct InteropStruct - { - [FieldOffset(0)] - public string Name; - - [FieldOffset(8)] - public int Year; - } -} From d379c0e68c344ea98681498c9f67e03a715528c2 Mon Sep 17 00:00:00 2001 From: Luke Latham <1622880+guardrex@users.noreply.github.com> Date: Tue, 1 Nov 2022 06:41:00 -0500 Subject: [PATCH 2/2] Delete CallJsExample10.razor --- .../call-js-from-dotnet/CallJsExample10.razor | 80 ------------------- 1 file changed, 80 deletions(-) delete mode 100644 7.0/BlazorSample_Server/Pages/call-js-from-dotnet/CallJsExample10.razor diff --git a/7.0/BlazorSample_Server/Pages/call-js-from-dotnet/CallJsExample10.razor b/7.0/BlazorSample_Server/Pages/call-js-from-dotnet/CallJsExample10.razor deleted file mode 100644 index 442e893f2..000000000 --- a/7.0/BlazorSample_Server/Pages/call-js-from-dotnet/CallJsExample10.razor +++ /dev/null @@ -1,80 +0,0 @@ -@page "/call-js-example-10" -@using System.Runtime.InteropServices -@using Microsoft.JSInterop -@inject IJSRuntime JS - -

Call JS Example 10

- -@if (callResultForBoolean) -{ -

JS interop was successful!

-} - -@if (!string.IsNullOrEmpty(callResultForString)) -{ -

@callResultForString

-} - -

- - -

- -

- Doctor Who - is a registered trademark of the BBC. -

- -@code { - private bool callResultForBoolean; - private string? callResultForString; - - private void CallJSUnmarshalledForBoolean() - { - var unmarshalledRuntime = (IJSUnmarshalledRuntime)JS; - - var jsUnmarshalledReference = unmarshalledRuntime - .InvokeUnmarshalled( - "returnObjectReference"); - - callResultForBoolean = - jsUnmarshalledReference.InvokeUnmarshalled( - "unmarshalledFunctionReturnBoolean", GetStruct()); - } - - private void CallJSUnmarshalledForString() - { - var unmarshalledRuntime = (IJSUnmarshalledRuntime)JS; - - var jsUnmarshalledReference = unmarshalledRuntime - .InvokeUnmarshalled( - "returnObjectReference"); - - callResultForString = - jsUnmarshalledReference.InvokeUnmarshalled( - "unmarshalledFunctionReturnString", GetStruct()); - } - - private InteropStruct GetStruct() - { - return new InteropStruct - { - Name = "Brigadier Alistair Gordon Lethbridge-Stewart", - Year = 1968, - }; - } - - [StructLayout(LayoutKind.Explicit)] - public struct InteropStruct - { - [FieldOffset(0)] - public string Name; - - [FieldOffset(8)] - public int Year; - } -}