private void App_BackRequested(object sender, BackRequestedEventArgs e) { var navigationManager = _container.GetInstance <INavigationManager>(); navigationManager.GoBack(); e.Handled = true; }
protected override object GetInstance(Type service, string key) { var instance = _container.GetInstance(service, key); if (instance != null) { return(instance); } throw new Exception("Could not locate any instances."); }
protected override void OnActivated(IActivatedEventArgs args) { if (args.Kind == ActivationKind.Protocol) { var protocolArgs = (ProtocolActivatedEventArgs)args; (var success, var owner, var name) = ParseProtocol(protocolArgs.Uri); if (success) { var eventAggregator = container.GetInstance <IEventAggregator>(); eventAggregator.PublishOnCurrentThread(new RepositorySelectedMessage(owner, name)); } } }
public override void ConfigureContainer(WinRTContainer container) { container .PerRequest <LoggedOutApplicationMode>() .PerRequest <LoggedInApplicationMode>(); container .Singleton <ICentronService, CentronService>() .Singleton <IHelpdeskGroupsService, HelpdeskGroupsService>() .Singleton <IQueryExecutor, QueryExecutor>() .Singleton <IQueryCache, QueryCache>() .Singleton <ICommandQueue, CommandQueue>() .Singleton <IScriptEngine, ScriptEngine>(); container .PerRequest <IQueryHandler <HelpdeskGroupQuery, IList <HelpdeskPreview> >, HelpdeskGroupQueryHandler>() .PerRequest <IQueryHandler <SearchCustomersQuery, IList <CustomerPreview> >, SearchCustomersQueryHandler>() .PerRequest <IQueryHandler <HelpdeskTypesQuery, IList <HelpdeskType> >, HelpdeskTypesQueryHandler>() .PerRequest <IQueryHandler <HelpdeskStatesQuery, IList <HelpdeskState> >, HelpdeskStatesQueryHandler>(); container .PerRequest <ICommandHandler <ChangeHelpdeskStateCommand, Unit>, ChangeHelpdeskStateCommandHandler>(); var scriptEngine = container.GetInstance <IScriptEngine>(); scriptEngine.AddGlobalMethod("contains", (Func <string, string, bool>)((s1, s2) => (s1 ?? string.Empty).IndexOf(s2, StringComparison.OrdinalIgnoreCase) >= 0)); }
protected override void Configure() { var baseGetLog = LogManager.GetLog; LogManager.GetLog = t => t == typeof(ViewModelBinder) ? new DebugLog(t) : baseGetLog(t); ConfigureSpecialValues(); container = new WinRTContainer(); container.RegisterWinRTServices(); container .Singleton <ISchemeStorageService, SchemeStorageService>() .Singleton <IWindowManager, WindowManager>() .Singleton <IBitmapService, BitmapService>() .Singleton <ITileService, TileService>() .Singleton <IAppSettingsService, AppSettingsService>(); container .PerRequest <SchemeListViewModel>() .PerRequest <EditSchemeViewModel>(); container.RegisterSharingService(); #if WINDOWS_PHONE_APP var statusBar = StatusBar.GetForCurrentView(); statusBar.HideAsync(); #endif var tileService = container.GetInstance <ITileService>(); tileService.Initialise(); }
protected override void Configure() { _container = new WinRTContainer(); _container.RegisterWinRTServices(); _eventAggregator = _container.GetInstance <IEventAggregator>(); }
public void RegisterFrame(Frame frame) { MarkedUp.AnalyticClient.RegisterNavigationFrame(frame); container.RegisterNavigationService(frame); navigationService = container.GetInstance <INavigationService>(); }
protected override void Configure() { _container = new WinRTContainer(); _container.RegisterWinRTServices(); _container.Handler <VehicleContext>(sc => { var optionsBuilder = new DbContextOptionsBuilder <VehicleContext>(); optionsBuilder.UseInMemoryDatabase("vehicle"); return(new VehicleContext(optionsBuilder.Options)); }); _container.Handler <MasterContext>(sc => { var optionsBuilder = new DbContextOptionsBuilder <MasterContext>(); optionsBuilder.UseInMemoryDatabase("master"); return(new MasterContext(optionsBuilder.Options)); }); // Make sure to register your containers here _container //.Instance<IConfigurationService>(new ConfigurationService()) .Singleton <UserSessionService>() .PerRequest <WelcomeViewModel>() .PerRequest <VehicleTypeSelectViewModel>() .PerRequest <CarAddViewModel>() .PerRequest <ShellViewModel>() .PerRequest <PivotViewModel>() .PerRequest <EventListViewModel>() .PerRequest <EventTypeSelectViewModel>() .PerRequest <FillUpAddViewModel>() ; this._eventAggregator = _container.GetInstance <IEventAggregator>(); var vehicleContext = _container.GetInstance <VehicleContext>(); vehicleContext.FillDummyData(); //var mainContext = _container.GetInstance<MasterContext>(); //mainContext.FillDummyData(); }
protected override void Configure() { _container = new WinRTContainer(); _container.RegisterWinRTServices(); //_container.PerRequest<ShellViewModel>(); _eventAggregator = _container.GetInstance <IEventAggregator>(); }
public async Task ActivateAsync(object activationArgs) { if (IsInteractive(activationArgs)) { // Initialize services that you need before app activation // take into account that the splash screen is shown while this code runs. await InitializeAsync(); // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (Window.Current.Content == null) { // Create a Shell or Frame to act as the navigation context if (_shell?.Value == null) { var frame = new Frame(); NavigationService = _container.RegisterNavigationService(frame); Window.Current.Content = frame; } else { var viewModel = ViewModelLocator.LocateForView(_shell.Value); ViewModelBinder.Bind(viewModel, _shell.Value, null); ScreenExtensions.TryActivate(viewModel); NavigationService = _container.GetInstance <INavigationService>(); Window.Current.Content = _shell?.Value; } } } var activationHandler = GetActivationHandlers() .FirstOrDefault(h => h.CanHandle(activationArgs)); if (activationHandler != null) { await activationHandler.HandleAsync(activationArgs); } if (IsInteractive(activationArgs)) { var defaultHandler = new DefaultActivationHandler(_defaultNavItem, NavigationService); if (defaultHandler.CanHandle(activationArgs)) { await defaultHandler.HandleAsync(activationArgs); } // Ensure the current window is active Window.Current.Activate(); // Tasks after activation await StartupAsync(); } }
public void RegisterFrame(Frame frame) { container.RegisterNavigationService(frame); navigationService = container.GetInstance <INavigationService>(); navigationService.Navigated += (s, e) => NotifyOfPropertyChange(nameof(CanGoBack)); navigationService.NavigateToViewModel <MenuViewModel>(); }
protected override void Configure() { #if DEBUG LogManager.GetLog = type => new CaliburnDebugLogger(type); #endif _container = new WinRTContainer(); _container.RegisterWinRTServices(); _container.Singleton <GattInformationProvider>().GetInstance <GattInformationProvider>().Initialize(); _container.Singleton <InfoManager>(); _container.Instance(new CommandRunner()); _container.Singleton <EventTracer>(); _container.Singleton <CharacteristicSubscriptionService>(); _container.Singleton <DeviceController>(); _container.Singleton <CommandPanelViewModel>(); _container.Singleton <Services.ApplicationSettings>(); _container.Singleton <ApplicationState>(); _container .PerRequest <MainViewModel>() .PerRequest <DeviceShellViewModel>() .PerRequest <SettingsViewModel>() .PerRequest <SelectDeviceViewModel>() .PerRequest <AboutViewModel>(); _container .PerRequest <ICommandFormatter, ReadFormatter>() .PerRequest <ICommandFormatter, WriteFormatter>() .PerRequest <ICommandFormatter, ReadClientConfigDescriptorFormatter>() .PerRequest <ICommandFormatter, WriteClientConfigDescriptorFormatter>() .PerRequest <ICommandFormatter, SubscribeFormatter>() .PerRequest <ICommandFormatter, UnsubscribeFormatter>() .PerRequest <ICommandFormatter, ConnectDeviceFormatter>() .PerRequest <ICommandFormatter, DisconnectDeviceFormatter>(); var tracer = _container.GetInstance <EventTracer>(); _eventAggregator = _container.GetInstance <IEventAggregator>(); }
public async Task ActivateAsync(object activationArgs) { if (IsInteractive(activationArgs)) { // Initialize things like registering background task before the app is loaded await InitializeAsync(); // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (Window.Current.Content == null) { // Create a Frame to act as the navigation context and navigate to the first page if (_shell?.Value == null) { var frame = new Frame(); NavigationService = _container.RegisterNavigationService(frame); Window.Current.Content = frame; } else { var viewModel = ViewModelLocator.LocateForView(_shell.Value); ViewModelBinder.Bind(viewModel, _shell.Value, null); ScreenExtensions.TryActivate(viewModel); NavigationService = _container.GetInstance <INavigationService>(); Window.Current.Content = _shell?.Value; } } } var activationHandler = GetActivationHandlers() .FirstOrDefault(h => h.CanHandle(activationArgs)); if (activationHandler != null) { await activationHandler.HandleAsync(activationArgs); } if (IsInteractive(activationArgs)) { var defaultHandler = new DefaultLaunchActivationHandler(_defaultNavItem, NavigationService); if (defaultHandler.CanHandle(activationArgs)) { await defaultHandler.HandleAsync(activationArgs); } // Ensure the current window is active Window.Current.Activate(); // Tasks after activation await StartupAsync(); } }
protected override object GetInstance(Type service, string key) { try { return(_container.GetInstance(service, key)); } catch (Exception ex) { throw new Exception(String.Format("Unable to resolve service '{0}' with key '{1}'.", service.Name, key), ex); } }
protected override void Configure() { LogManager.GetLog = type => new DebugLog(type); _container = new WinRTContainer(); _container.RegisterWinRTServices(); _container .PerRequest <ShellViewModel>() .PerRequest <TestViewModel>(); _eventAggregator = _container.GetInstance <IEventAggregator>(); }
protected override void Configure() { _container = new WinRTContainer(); _container.RegisterWinRTServices(); _container .PerRequest<ShellViewModel>() .PerRequest<DeviceViewModel>(); _eventAggregator = _container.GetInstance<IEventAggregator>(); }
private void AddTab() { var newIndex = Items.Any() ? Items.Max((IScreen screen) => (screen as RunnerInstanceViewModel).Index) + 1 : 1; var runnerInstanceVM = _container.GetInstance <RunnerInstanceViewModel>(); runnerInstanceVM.Index = (short)newIndex; runnerInstanceVM.Header = "RunnerInstance_EmptyHeader".GetLocalized(); Items.Add(item: runnerInstanceVM); }
protected override void Configure() { _container = new WinRTContainer(); _container.RegisterWinRTServices(); // Make sure to register your containers here _container .PerRequest <DragDropViewModel>() ; _eventAggregator = _container.GetInstance <IEventAggregator>(); }
/// <summary> /// Override to configure the framework and setup your IoC container. /// </summary> protected override void Configure() { _container = new WinRTContainer(); _container.RegisterWinRTServices(); _container.Singleton <IDialogWindowManager, DialogWindowManager>(); _container.Singleton <IUserNotificationService, UserNotificationService>(); this.RegistInstances(this._container); _eventAggregator = _container.GetInstance <IEventAggregator>(); }
public MainPageView() { this.InitializeComponent(); NavigationCacheMode = NavigationCacheMode.Required; WinRTContainer container = (Application.Current as App).container; IEventAggregator eventAggregator = container.GetInstance <IEventAggregator>(); eventAggregator.Subscribe(this); }
protected override void Configure() { ApplicationLanguages.PrimaryLanguageOverride = GlobalizationPreferences.Languages[0]; #region Migrations using (var db = new AppDbContext()) { db.Database.Migrate(); } #endregion _container = new WinRTContainer(); _container.RegisterWinRTServices(); _container .Singleton <ShellPageViewModel>() .Singleton <LibraryPageViewModel>() .PerRequest <BookPageViewModel>() .PerRequest <BookImportPageViewModel>() .Singleton <AppDbContext>() .Singleton <IMenuProvider, ShellMenuProvider>() .Singleton <IDbBookProvider, AppDbBookProvider>() .Singleton <IStorageBookProvider, LocalStorageBookProvider>() .Singleton <IBookLinesProvider, BookLinesProvider>() .Singleton <IFictionBookFormatter, FictionBookFormatter>() .Singleton <IBookManager, BookManager>(); //#if DEBUG // .Singleton<IInAppPurchase, SimulatorInAppPurchase>(); //#else // .Singleton<IInAppPurchase, MarketInAppPurchase>(); //#endif _eventAggregator = _container.GetInstance <IEventAggregator>(); var navigation = SystemNavigationManager.GetForCurrentView(); navigation.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible; navigation.BackRequested += (o, e) => { e.Handled = true; var n = IoC.Get <INavigationService>(); if (n.CanGoBack) { n.GoBack(); } }; }
protected override void Configure() { //var config = LoadConfig(); _container = new WinRTContainer(); _container.RegisterWinRTServices(); _container.UseMapEditor(); _container.UseResource() .UseResourceManager(new Uri("ms-appx:///Assets/Config/Shaders.json"), new Uri("ms-appx:///Assets/Config/TileSets.json"), new Uri("ms-appx:///Assets/Config/Sprites/Infantry.json"), new Uri("ms-appx:///Assets/Config/Art/Infantry.json")) .UseRulesLoader(new Uri("ms-appx:///Assets/Config/Rules/Infantry.json")); _container.UseAudio(); _eventAggregator = _container.GetInstance <IEventAggregator>(); ViewModelBinder.ApplyConventionsByDefault = false; }
protected override void OnLaunched(LaunchActivatedEventArgs e) { #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { this.DebugSettings.EnableFrameRateCounter = true; } #endif Initialize(); container.GetInstance <IAnalytics>().StartSession(); DisplayRootView <HomeView>(); }
protected override void Configure() { MarkedUp.AnalyticClient.Initialize("5809dd47-4d72-4c1e-b125-c7272bfc149d"); container = new WinRTContainer(); container .Instance(container); container .Singleton <IEventAggregator, EventAggregator>() .Singleton <IPlayHistoryService, PlayHistoryService>() .Singleton <IApplicationSettingsService, ApplicationSettingsService>(); container .PerRequest <MediaHubViewModel>() .PerRequest <BrowseFolderViewModel>() .PerRequest <SearchResultsViewModel>() .PerRequest <AboutViewModel>() .PerRequest <PrivacyPolicyViewModel>() .PerRequest <PlayHistoryViewModel>(); var settings = container.RegisterSettingsService(); settings.RegisterFlyoutCommand <AboutViewModel>(Strings.SettingsAbout); settings.RegisterFlyoutCommand <PrivacyPolicyViewModel>(Strings.SettingsPrivacyPolicy); ApplicationData.Current.SetVersionAsync(1, async r => { if (r.CurrentVersion == 0 && r.DesiredVersion == 1) { var deferral = r.GetDeferral(); var playHistory = container.GetInstance <IPlayHistoryService>(); await playHistory.MigrateToDictionaryAsync(); deferral.Complete(); } }); }
protected override void Configure() { //MessageBinder.SpecialValues.Add("$clickeditem", c => ((ItemClickEventArgs)c.EventArgs).ClickedItem); var config = new TypeMappingConfiguration { DefaultSubNamespaceForViews = "Views", DefaultSubNamespaceForViewModels = "ViewModels" }; ViewLocator.ConfigureTypeMappings(config); ViewModelLocator.ConfigureTypeMappings(config); _container = new WinRTContainer(); _container.RegisterWinRTServices(); RegisterViewModels(); RegisterServices(); _eventAggregator = _container.GetInstance <IEventAggregator>(); }
protected override void Configure() { // This configures the framework to map between MainViewModel and MainPage // Normally it would map between MainPageViewModel and MainPage var config = new TypeMappingConfiguration { IncludeViewSuffixInViewModelNames = false }; ViewLocator.ConfigureTypeMappings(config); ViewModelLocator.ConfigureTypeMappings(config); _container = new WinRTContainer(); _container.RegisterWinRTServices(); _container.PerRequest <MainViewModel>() .PerRequest <ServerViewModel>() .PerRequest <SettingViewModel>() .Singleton <AppService>(); var appService = _container.GetInstance <AppService>(); }
protected override void Configure() { MessageBinder.SpecialValues.Add("$clickedItem", c => ((ItemClickEventArgs)c.EventArgs).ClickedItem); container = new WinRTContainer(); container.RegisterWinRTServices(); container .PerRequest <ShellViewModel>() .PerRequest <MediaViewModel>() .PerRequest <BackgroundTaskViewModel>() .PerRequest <BindingViewModel>() .PerRequest <ConnectedAnimationsViewModel>() .PerRequest <AnimationsTargetViewModel>() .PerRequest <ControlsViewModel>() .PerRequest <DetectionViewModel>() .PerRequest <EffectsViewModel>() .PerRequest <ImplicitAnimationsViewModel>() .PerRequest <InkingViewModel>() .PerRequest <LinksViewModel>() .PerRequest <XboxViewModel>() .PerRequest <HoloLensViewModel>() .PerRequest <WebsiteViewModel>(); var appView = ApplicationView.GetForCurrentView(); var coreApp = CoreApplication.GetCurrentView(); appView.TitleBar.BackgroundColor = Color.FromArgb(255, 30, 30, 30); appView.TitleBar.ButtonBackgroundColor = Color.FromArgb(255, 30, 30, 30); appView.TitleBar.ButtonHoverBackgroundColor = Color.FromArgb(255, 3, 169, 244); coreApp.TitleBar.ExtendViewIntoTitleBar = true; eventAggregator = container.GetInstance <IEventAggregator>(); }
protected override object GetInstance(Type service, string key) { return _container.GetInstance(service, key); }