sharee.bike-App/ShareeBike/ShareeBike/BackdoorMethodHelpers.cs

35 lines
993 B
C#
Raw Permalink Normal View History

2023-11-06 12:23:09 +01:00
using System.Linq;
2024-04-09 12:53:23 +02:00
using ShareeBike.View.Map;
using ShareeBike.ViewModel.Map;
2021-11-07 19:42:59 +01:00
using Xamarin.Forms;
2024-04-09 12:53:23 +02:00
namespace ShareeBike
2021-11-07 19:42:59 +01:00
{
2022-09-06 16:08:19 +02:00
public static class BackdoorMethodHelpers
{
public static void DoTapPage(string stationId)
{
Serilog.Log.Information($"Request via backdoor to tap station {stationId}.");
var currentPage = GetCurrentPage();
var mapPageViewModel = (currentPage as MapPage)?.BindingContext as MapPageViewModel;
if (mapPageViewModel == null)
{
Serilog.Log.Error($"Request via backdoor to tap station {stationId} aborted because current page is not of expected type {typeof(MapPage).Name}. Type detected is {currentPage.GetType().Name}.");
return;
}
2021-11-07 19:42:59 +01:00
2022-09-06 16:08:19 +02:00
Serilog.Log.Information($"Invoking member to tap.");
mapPageViewModel?.OnStationClicked(stationId);
}
2021-11-07 19:42:59 +01:00
2022-09-06 16:08:19 +02:00
/// <summary> Gets the current page assumed that app is master detail page.</summary>
/// <returns></returns>
static Page GetCurrentPage()
{
2021-11-07 19:42:59 +01:00
2022-09-06 16:08:19 +02:00
return Shell.Current.CurrentPage;
}
2021-11-07 19:42:59 +01:00
2022-09-06 16:08:19 +02:00
}
2021-11-07 19:42:59 +01:00
}