-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
42 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,5 +10,4 @@ public static MauiAppBuilder UsePlatformChannels(this MauiAppBuilder builder, Ch | |
|
||
return builder; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,50 @@ | ||
using Microsoft.PlatformChannels; | ||
|
||
namespace SamplePlatformChannels; | ||
|
||
public partial class MainPage : ContentPage | ||
{ | ||
|
||
public MainPage(IChannelService channelService) | ||
{ | ||
ChannelService = channelService; | ||
public MainPage(IChannelService channelService) | ||
{ | ||
ChannelService = channelService; | ||
|
||
InitializeComponent(); | ||
} | ||
InitializeComponent(); | ||
} | ||
|
||
public readonly IChannelService ChannelService; | ||
public readonly IChannelService ChannelService; | ||
|
||
void Button_Clicked(System.Object sender, System.EventArgs e) | ||
{ | ||
void Button_Clicked(System.Object sender, System.EventArgs e) | ||
{ | ||
labelViewChannel.SendToPlatform("setText", "Hello, From MAUI!"); | ||
labelViewChannel2.SendToPlatform("setText", "Hello again, From MAUI!"); | ||
|
||
|
||
if (string.IsNullOrEmpty(entryNumbers?.Text)) | ||
return; | ||
return; | ||
|
||
// Math service, use independently | ||
|
||
var mathChannel = ChannelService.GetOrCreateChannel("math"); | ||
|
||
var entered = entryNumbers.Text.Split(' ', ',', ';'); | ||
var mathChannel = ChannelService.GetOrCreateChannel("math"); | ||
|
||
var entered = entryNumbers.Text.Split(' ', ',', ';'); | ||
|
||
var items = new List<object>(); | ||
var items = new List<object>(); | ||
|
||
foreach (var n in entered) | ||
{ | ||
if (double.TryParse(n, out var ndbl)) | ||
items.Add(ndbl); | ||
} | ||
foreach (var n in entered) | ||
{ | ||
if (double.TryParse(n, out var ndbl)) | ||
items.Add(ndbl); | ||
} | ||
|
||
var itemsArr = items.ToArray(); | ||
var result = mathChannel.SendToPlatform("add", itemsArr); | ||
var itemsArr = items.ToArray(); | ||
var result = mathChannel.SendToPlatform("add", itemsArr); | ||
|
||
if (result is double dbl) | ||
labelResult.Text = dbl.ToString(); | ||
} | ||
if (result is double dbl) | ||
labelResult.Text = dbl.ToString(); | ||
} | ||
|
||
private object PlatformChannelView_OnReceiveFromPlatform(string messageId, object parameters) | ||
{ | ||
return null; | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters