public App() { InitializeComponent(); AppContainer.RegisterDependencies(); _navigationSvc = AppContainer.Resolve <INavigationService>(); _ = InitializeNavigationAsync(); }
public App() { InitializeComponent(); AppContainer.RegisterDependencies(); var navigationService = AppContainer.Resolve <INavigationService>(); navigationService.InitializeAsync(); }
protected override Task InitializeServicesAsync() { if (!IsApplicationAttached) { throw new InvalidOperationException("No application attached to background service. Unable to resolve services."); } _factService = AppContainer.Resolve <IFactService>(); return(Task.CompletedTask); }
public App() { InitializeComponent(); AppContainer.RegisterDependencies(); AppContainer.Resolve <EmployeeHelpViewModel>(); MainPage = new NavigationPage(new ScanView() { BindingContext = AppContainer.Resolve <ScanViewModel>() }); }
public AppShell() { InitializeComponent(); Shell.SetBackgroundColor(this, Color.FromHex("ED028C")); Shell.SetForegroundColor(this, Color.White); Shell.SetTabBarIsVisible(this, false); viewModel = new AppShellViewModel(AppContainer.Resolve <IBackendService>()); BindingContext = viewModel; }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); AppContainer.RegisterDependencies(); var viewModel = AppContainer.Resolve <MainViewModel>(); var window = new MainWindow(); window.DataContext = viewModel; window.Show(); }
private void InitializeApp() { AppContainer.RegisterDependencies(); var shoppingCartViewModel = AppContainer.Resolve <ShoppingCartViewModel>(); shoppingCartViewModel.InitializeMessenger(); var logOutViewModel = AppContainer.Resolve <LogOutViewModel>(); logOutViewModel.InitializeMessaeger(); }
public PlanTripViewModel(ITeacherService teacherService, IToddlerService toddlerService, ITripService tripService) { teacherService = AppContainer.Resolve <ITeacherService>(); toddlerService = AppContainer.Resolve <IToddlerService>(); tripService = AppContainer.Resolve <ITripService>(); _teacherService = teacherService; _toddlerService = toddlerService; _tripService = tripService; confirmTripClicked = new RelayCommand(onTripConfirmedClick); //Mocking automatic assignment of a ID in a live database index = _tripService.getAllTrips().Count(); }
public App() { InitializeComponent(); AppContainer.Init(); var mainPage = new NavigationPage(new AssetsPage()); var vm = AppContainer.Resolve <AssetsViewModel>(); mainPage.BindingContext = vm; var navService = AppContainer.Resolve <INavService>() as NavService; navService.XamarinFormsNav = mainPage.Navigation; MainPage = mainPage; }
public ScanViewModel(INavigationService navigationService, IScanService scanService, IToddlerService toddlerService, ITripService tripService, ITeacherService teacherService) { scanService = AppContainer.Resolve <IScanService>(); toddlerService = AppContainer.Resolve <IToddlerService>(); tripService = AppContainer.Resolve <ITripService>(); teacherService = AppContainer.Resolve <ITeacherService>(); _navigationService = navigationService; _scanService = scanService; _toddlerService = toddlerService; _tripService = tripService; _teacherService = teacherService; QRScanned = new Command(tripScan); }
} // AC stands for Anti-Cheat in this context and not Air-Conditioning public QuestionPage() { InitializeComponent(); viewModel = new QuestionViewModel(AppContainer.Resolve <INavigationService>()); BindingContext = viewModel; IsACEnabled = true; MessagingCenter.Instance.Subscribe <QuestionViewModel, bool>(this, "IsACEnabled", (sender, isACEnabled) => { IsACEnabled = isACEnabled; }); Connectivity.Instance.ConnectivityChanged += HandleConnectivityChanged; }
public App() { InitializeComponent(); AppContainer.RegisterDependencies(); var main = new LoginView { BindingContext = AppContainer.Resolve <LoginViewModel>() }; MainPage = main; //MainPage = new NavigationPage(new LoginPage {Title = "Quiz Time"}); }
//private readonly IStoreService storeService; //public TaskLocator() //{ //} public async Task RunFindOfferLocator(CancellationToken token) { var settings = await App.DataBase.GetSettingsAsync(1); var storeService = AppContainer.Resolve <IStoreService>(); var geoLocator = AppContainer.Resolve <IGeoLocator>(); var offersSent = new List <Store>(); await Task.Run(async() => { while (!token.IsCancellationRequested) { try { var userLocation = await geoLocator.GetLocationAsync(); if (userLocation == null) { await Task.Delay(settings.SearchOfferIntervalSeconds * 1000, token); continue; } var stores = await storeService.GetStoreOffersAsync(); var newStoreOffers = stores.Where(s => offersSent.FirstOrDefault(o => o.Name == s.Name) != null); foreach (var store in newStoreOffers) { Device.BeginInvokeOnMainThread(() => MessagingCenter.Send(store, "StoreOfferFound")); offersSent.Add(store); } //for (int j = stores.Count - 1; j > 0; j--) //{ // var store = stores[j]; // var distanceToStore = Location.CalculateDistance(userLocation, store.Location, DistanceUnits.Kilometers); // if (distanceToStore < settings.StoreOfferRadius) // { // Device.BeginInvokeOnMainThread(() => MessagingCenter.Send(store, "StoreOfferFound")); // stores.RemoveAt(j); // } //} } catch (Exception ex) { Debug.Write("FindOfferLocator failed. " + ex.Message); } await Task.Delay(settings.SearchOfferIntervalSeconds * 1000, token); } }, token); }
private Page CreateViewFor(Type viewModelType) { var viewType = GetViewTypeForViewModel(viewModelType); Page view = AppContainer.Resolve(viewType) as Page; BaseViewModel viewModel = AppContainer.Resolve(viewModelType) as BaseViewModel; if (view != null) { view.BindingContext = viewModel; return(view); } throw new InvalidOperationException("View was not found"); }
object GetViewModel <TParameter>(Type viewModelType, TParameter parameter) { var vm = AppContainer.Resolve(viewModelType); if (vm is BaseViewModel <TParameter> viewmodelParam) { viewmodelParam.Init(parameter); } else if (vm is BaseViewModel viewModel) { viewModel.Init(); } return(vm); }
protected Page CreateAndBindPage(Type viewModelType, object parameter) { Type pageType = GetPageTypeForViewModel(viewModelType); if (pageType == null) { throw new Exception($"Mapping type for {viewModelType} is not a page"); } Page page = Activator.CreateInstance(pageType) as Page; BaseViewModel viewModel = AppContainer.Resolve(viewModelType) as BaseViewModel; page.BindingContext = viewModel; return(page); }
public override bool FinishedLaunching(UIApplication app, NSDictionary options) { global::Xamarin.Forms.Forms.Init(); // Init plugins FFImageLoading.Forms.Platform.CachedImageRenderer.Init(); Toolkit.Init(); // Inject analytics service AppContainer.Build(); var analyticsService = AppContainer.Resolve <IAnalyticsService>(); LoadApplication(new App(analyticsService)); return(base.FinishedLaunching(app, options)); }
public async void OnDelete(object sender, EventArgs e) { var menuItem = (MenuItem)sender; var selectedServer = (Server)menuItem.CommandParameter; var servers = await BlobCache.UserAccount.GetObject <Servers>("Servers"); servers.MonitoredServers.Remove(servers.MonitoredServers.Where(i => i.ID == selectedServer.ID).Single()); await BlobCache.UserAccount.InsertObject("Servers", servers); var viewModel = AppContainer.Resolve <ServerMonitorViewModel>(); viewModel.Refresh(); }
protected Page CreateAndBindPage(Type viewModelType, PageNavigationMode navMode = PageNavigationMode.Modeless) { Type pageType = GetPageTypeForViewModel(viewModelType); if (pageType == null) { throw new Exception($"Mapping type for {viewModelType} is not a page"); } Page page = Activator.CreateInstance(pageType) as Page; ViewModelBase viewModel = AppContainer.Resolve(viewModelType) as ViewModelBase; viewModel.PageNavigationMode = navMode; page.BindingContext = viewModel; return(page); }
protected override void OnAppearing() { base.OnAppearing(); //Settings = await App.DataBase.GetSettingsAsync(1); //sliderLabelOffer.Text = $"Erbjudanderadie: {Settings.StoreOfferRadius} km"; //sliderOffer.Value = Settings.StoreOfferRadius; //sliderLabelSearch.Text = $"Sök erbjudanden intervall: {Settings.SearchOfferIntervalSeconds} sek"; //sliderSearch.Value = Settings.SearchOfferIntervalSeconds; //var userLocation = await GeoLocator.GetLocationAsync(); SettingsView = new SettingsView(AppContainer.Resolve <IGeoLocator>()); BindingContext = SettingsView; }
private async void Add() { IsButtonEnabled = false; IsBusy = true; var inputDomain = HostName ?? ""; var preDomain = inputDomain.ToLower(); var domain = "https://" + preDomain; var isDomainValid = await _serverChecker.CheckIfDomainIsValidAsync(domain); if (isDomainValid == true) { var newServersList = await BlobCache.UserAccount.GetObject <Servers>("Servers"); newServersList.MonitoredServers.Add(new Server { ID = Guid.NewGuid().ToString(), Name = Name, HostName = domain }); await BlobCache.UserAccount.InsertObject("Servers", newServersList); IsBusy = false; //Clear screen Name = ""; HostName = ""; Shell.Current.SendBackButtonPressed(); var viewModel = AppContainer.Resolve <ServerMonitorViewModel>(); viewModel.Refresh(); } else { IsBusy = false; await Application.Current.MainPage.DisplayAlert("Error", $"Use a valid domain and check network connection.", "OK"); } IsButtonEnabled = true; }
private PopupPage CreatePage(Type viewModelType, Dictionary <string, object> parameter, ICommand ClosedCommand) { Type pageType = GetPageTypeForViewModel(viewModelType); if (pageType == null) { throw new Exception($"Cannot locate page type for {viewModelType}"); } PopupPage page = Activator.CreateInstance(pageType) as PopupPage; var model = AppContainer.Resolve(viewModelType) as PopupModelBase; model.ClosedCommand = ClosedCommand; page.Disappearing += (e, a) => { try { model._cts.Cancel(); model._cts.Dispose(); } catch { } }; model.Initialize(parameter); page.BindingContext = model; return(page); }
private object DispatcherOperationCallback(object arg) { DebugLog(nameof(DispatcherOperationCallback)); AppInitialize(); MainWindow mainWindow; try { mainWindow = AppContainer.Resolve <MainWindow>(); DebugLog($"Received {mainWindow} "); } catch (Exception ex) { DebugLog("Cant resolve main Window: " + ex.Message); // ReSharper disable once RedundantArgumentDefaultValue ErrorExit(ExitCode.GeneralError); return(null); } if (ShowMainWindow) { try { //mainWindow.WindowState = WindowState.Minimized ; mainWindow.Show(); } catch (Exception ex) { DebugLog(ex.Message); //?.Error ( ex , ex.Message ) ; } #if SHOWWINDOW var mainWindow = new MainWindow(); mainWindow.Show(); #endif } Initialized = true; return(null); }
public async Task NavigateToAsync <TViewModel>() { var viewModelType = typeof(TViewModel); var viewType = Type.GetType($"{viewModelType.FullName.Replace("Model", string.Empty)}, {viewModelType.GetTypeInfo().Assembly.FullName}"); var page = AppContainer.Resolve(viewType) as Page; var viewModel = AppContainer.Resolve(viewModelType) as ViewModelBase; page.BindingContext = viewModel; if (Application.Current.MainPage is null) { Application.Current.MainPage = new NavigationPage(page); } else { await Application.Current.MainPage.Navigation.PushAsync(page, true); } }
private void InitializeApp() { AppContainer.RegisterDependencies(); //if (!string.IsNullOrEmpty(OneSignalKey)) //{ // var appContext = AppContainer.Resolve<IApplicationContext>(); // OneSignal.Current.StartInit(OneSignalKey) // .HandleNotificationReceived(appContext.HandleNotificationReceived) // .EndInit(); // OneSignal.Current.IdsAvailable((userID, pushToken) => // { // var applicationContext = AppContainer.Resolve<IApplicationContext>(); // applicationContext.OneSignalUserID = userID; // applicationContext.OneSignalPushToken = pushToken; // }); //} var shoppingCartViewModel = AppContainer.Resolve <ShoppingCartViewModel>(); shoppingCartViewModel.InitializeMessenger(); }
public void Decode_DoesNotThrowOnValidData(string name) { // Arrange. var archiveFileName = $"Ssq.{name}.zip"; var inputFileName = $"{name}.ssq"; var inputFile = GetArchiveResource(archiveFileName).Single().Value; FileSystem.WriteAllBytes(inputFileName, inputFile); var subject = AppContainer.Resolve <SsqCliModule>(); var parsedArgs = AppContainer.Resolve <ArgParser>().Parse(new[] { inputFileName }); // Act. Action act = () => subject .Commands .Single(c => c.Name.Equals("decode", StringComparison.OrdinalIgnoreCase)) .TaskFactory(parsedArgs); // Assert. act.Should().NotThrow(); }
private static void OnAutoWireViewModelChanged(BindableObject bindable, object oldValue, object newValue) { if (!(bindable is Element view)) { return; } var viewType = view.GetType(); if (viewType.FullName != null) { var viewName = viewType.FullName.Replace(".Views.", ".ViewModels."); var viewAssemblyName = viewType.GetTypeInfo().Assembly.FullName; var viewModelName = string.Format(CultureInfo.InvariantCulture, "{0}Model, {1}", viewName, viewAssemblyName); var viewModelType = Type.GetType(viewModelName); if (viewModelType == null) { return; } var viewModel = AppContainer.Resolve(viewModelType); view.BindingContext = viewModel; } }
private void SetupTracing() { PresentationTraceSources.Refresh(); if (DoTracing) { var nLogTraceListener = new NLogTraceListener(); var routedEventSource = PresentationTraceSources.RoutedEventSource; nLogTraceListener.DefaultLogLevel = LogLevel.Debug; nLogTraceListener.ForceLogLevel = LogLevel.Warn; //nLogTraceListener.LogFactory = AppContainer.Resolve < LogFactory > ( ) ; nLogTraceListener.AutoLoggerName = false; //nLogTraceListener. routedEventSource.Switch.Level = SourceLevels.All; var foo = AppContainer.Resolve <IEnumerable <TraceListener> >(); foreach (var tl in foo) { routedEventSource.Listeners.Add(tl); } //routedEventSource.Listeners.Add ( new AppTraceListener ( ) ) ; routedEventSource.Listeners.Add(nLogTraceListener); } }
private Page CreatePage(Type viewModelType, Dictionary <string, object> navigationData) { try { Type pageType = GetPageTypeForViewModel(viewModelType); if (pageType == null) { throw new Exception($"Cannot locate page type for {viewModelType}"); } Page page = Activator.CreateInstance(pageType) as Page; var model = AppContainer.Resolve(viewModelType) as ViewModelBase; model.Initialize(navigationData); page.BindingContext = model; return(page); } catch (Exception ex) { var page = new Views.ErrorView(); page.BindingContext = ex.ToString(); return(page); } }
protected override void OnCreate(Bundle savedInstanceState) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(savedInstanceState); // Init plugins CrossCurrentActivity.Current.Init(this, savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); FFImageLoading.Forms.Platform.CachedImageRenderer.Init(enableFastRenderer: true); Toolkit.Init(); UserDialogs.Init(this); // Inject analytics service var analyticsService = AppContainer.Resolve <IAnalyticsService>(); LoadApplication(new App(analyticsService)); // Set the current activity so the AuthService knows where to start. AuthService.ParentWindow = CrossCurrentActivity.Current.Activity; }