private async void GoLive(IWebViewComponent viewControl) { if (Mode != ApplicationMode.Dev) { return; } var resourceLoader = GetResourceReader(); var createOverlay = resourceLoader.Load("loading.js"); viewControl.ExecuteJavascript(createOverlay); var cancellationTokenSource = new CancellationTokenSource(); var token = cancellationTokenSource.Token; DebugCommands.Clear(); DebugCommands["Cancel to live"] = new RelayToogleCommand <ICompleteWebViewComponent> (_ => { cancellationTokenSource.Cancel(); UpdateCommands(); }); try { await Task.Run(() => DoGoLive(viewControl, token), token); } catch (TaskCanceledException) { var removeOverlay = resourceLoader.Load("removeOverlay.js"); viewControl.ExecuteJavascript(removeOverlay); return; } await viewControl.SwitchViewAsync(Uri); }
private async Task ChangeMode(IWebViewComponent viewControl, ApplicationMode destination, string change) { if (Mode == destination) { return; } var resourceLoader = GetResourceReader(); var createOverlay = resourceLoader.Load("loading.js"); viewControl.ExecuteJavascript(createOverlay); var cancellationTokenSource = new CancellationTokenSource(); var token = cancellationTokenSource.Token; DebugCommands.Clear(); DebugCommands[$"Cancel {change}"] = new RelayToogleCommand <ICompleteWebViewComponent> (_ => { cancellationTokenSource.Cancel(); UpdateCommands(); }); try { await Task.Run(() => DoChange(viewControl, destination, token), token); } catch (TaskCanceledException) { var removeOverlay = resourceLoader.Load("removeOverlay.js"); viewControl.ExecuteJavascript(removeOverlay); return; } await viewControl.SwitchViewAsync(Uri); }
public RelayToogleCommandTest() { _Action = Substitute.For <Action>(); _RelayToogleCommand = new RelayToogleCommand(_Action); }
public RelayToogleCommandGenericTest() { _Action = Substitute.For <Action <string> >(); _RelayToogleCommand = new RelayToogleCommand <string>(_Action); }