Пример #1
0
 public MessagingSamplesController(HybridMessagingHandler hybridMessaging)
 {
     hybridMessaging.Subscribe("", () =>
     {
         var xResult = hybridMessaging.Send <int, string>("NewMessageID",
                                                          "This is a string message argument send from C# side. We expect an int as the result of this event.");
         // ReSharper disable once UnusedVariable
         var uselessVariable = CoreApplication.MainView.CoreWindow.Dispatcher
                               .RunAsync(CoreDispatcherPriority.Normal, async() =>
         {
             await new MessageDialog(
                 "This is a simple AlertDialog created by the C# side for all messages. We sent a message with message identification of: 'NewMessageID' and result of that message was: " +
                 (xResult == default(int) ? "[NODATA]" : xResult.ToString())).ShowAsync().AsTask();
         });
     });
     hybridMessaging.Subscribe("MyMessageID", (SampleModel model) =>
     {
         // ReSharper disable once UnusedVariable
         var uselessVariable = CoreApplication.MainView.CoreWindow.Dispatcher
                               .RunAsync(CoreDispatcherPriority.Normal, async() =>
         {
             await
             new MessageDialog(
                 "This is a simple AlertDialog created by the C# side for 'MyMessageID' message. Model.StringValue = " +
                 model.StringValue).ShowAsync().AsTask();
         });
     });
 }
 public MessagingSamplesController(Activity parentActivity, HybridMessagingHandler hybridMessaging)
 {
     hybridMessaging.Subscribe("", () =>
     {
         var xResult = hybridMessaging.Send <int, string>("NewMessageID",
                                                          "This is a string message argument send from C# side. We expect an int as the result of this event.");
         parentActivity.RunOnUiThread(() =>
         {
             new AlertDialog.Builder(parentActivity)
             .SetMessage(
                 "This is a simple AlertDialog created by the C# side for all messages. We sent a message with message identification of: 'NewMessageID' and result of that message was: " +
                 (xResult == default(int) ? "[NODATA]" : xResult.ToString()))
             .Show();
         });
     });
     hybridMessaging.Subscribe("MyMessageID", (SampleModel model) =>
     {
         parentActivity.RunOnUiThread(() =>
         {
             new AlertDialog.Builder(parentActivity)
             .SetMessage(
                 "This is a simple AlertDialog created by the C# side for 'MyMessageID' message. Model.StringValue = " +
                 model.StringValue)
             .Show();
         });
     });
 }
 public MessagingSamplesController(HybridMessagingHandler hybridMessaging)
 {
     hybridMessaging.Subscribe("", () =>
     {
         var xResult = hybridMessaging.Send <int, string>("NewMessageID",
                                                          "This is a string message argument send from C# side. We expect an int as the result of this event.");
         DispatchQueue.MainQueue.DispatchAsync(() =>
         {
             using (
                 var alertView = new UIAlertView(@"C# UIAlertView",
                                                 @"This is a simple AlertDialog created by the C# side for all messages. We sent a message with message identification of: 'NewMessageID' and result of that message was: " +
                                                 (xResult == default(int) ? "[NODATA]" : xResult.ToString()),
                                                 null, @"Ok", null))
             {
                 alertView.Show();
             }
         });
     });
     hybridMessaging.Subscribe("MyMessageID", (SampleModel model) =>
     {
         DispatchQueue.MainQueue.DispatchAsync(() =>
         {
             using (
                 var alertView = new UIAlertView(@"C# UIAlertView",
                                                 @"This is a simple AlertDialog created by the C# side for 'MyMessageID' message. Model.StringValue = " +
                                                 model.StringValue,
                                                 null, @"Ok", null))
             {
                 alertView.Show();
             }
         });
     });
 }