diff --git a/9.0/UserInterface/Views/HybridWebViewDemo/HybridWebViewDemo/MainPage.xaml.cs b/9.0/UserInterface/Views/HybridWebViewDemo/HybridWebViewDemo/MainPage.xaml.cs index 2416c7628..12ce64cb2 100644 --- a/9.0/UserInterface/Views/HybridWebViewDemo/HybridWebViewDemo/MainPage.xaml.cs +++ b/9.0/UserInterface/Views/HybridWebViewDemo/HybridWebViewDemo/MainPage.xaml.cs @@ -10,7 +10,7 @@ public partial class MainPage : ContentPage public MainPage() { InitializeComponent(); - hybridWebView.SetInvokeJavaScriptTarget(new DotNetMethods(this)); + hybridWebView.SetInvokeJavaScriptTarget(this); } private void OnSendMessageButtonClicked(object sender, EventArgs e) @@ -61,6 +61,32 @@ private void hybridWebView_RawMessageReceived(object sender, HybridWebViewRawMes Dispatcher.Dispatch(() => editor.Text += Environment.NewLine + e.Message); } + public void DoSyncWork() + { + Debug.WriteLine("DoSyncWork"); + } + + public void DoSyncWorkParams(int i, string s) + { + Debug.WriteLine($"DoSyncWorkParams: {i}, {s}"); + } + + public string DoSyncWorkReturn() + { + Debug.WriteLine("DoSyncWorkReturn"); + return "Hello from C#!"; + } + + public SyncReturn DoSyncWorkParamsReturn(int i, string s) + { + Debug.WriteLine($"DoSyncWorkParamReturn: {i}, {s}"); + return new SyncReturn + { + Message = "Hello from C#!" + s, + Value = i + }; + } + public class ComputationResult { public double result { get; set; } @@ -78,42 +104,6 @@ internal partial class HybridSampleJSContext : JsonSerializerContext // for trimmed builds. } - private class DotNetMethods - { - MainPage _mainPage; - - public DotNetMethods(MainPage mainPage) - { - _mainPage = mainPage; - } - - public void DoSyncWork() - { - Debug.WriteLine("DoSyncWork"); - } - - public void DoSyncWorkParams(int i, string s) - { - Debug.WriteLine($"DoSyncWorkParams: {i}, {s}"); - } - - public string DoSyncWorkReturn() - { - Debug.WriteLine("DoSyncWorkReturn"); - return "Hello from C#!"; - } - - public SyncReturn DoSyncWorkParamsReturn(int i, string s) - { - Debug.WriteLine($"DoSyncWorkParamReturn: {i}, {s}"); - return new SyncReturn - { - Message = "Hello from C#!" + s, - Value = i - }; - } - } - public class SyncReturn { public string? Message { get; set; }