Ejemplo n.º 1
0
        private void App_BackRequested(object sender, BackRequestedEventArgs e)
        {
            var navigationManager = _container.GetInstance <INavigationManager>();

            navigationManager.GoBack();
            e.Handled = true;
        }
Ejemplo n.º 2
0
        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.");
        }
Ejemplo n.º 3
0
        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));
                }
            }
        }
Ejemplo n.º 4
0
        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));
        }
Ejemplo n.º 5
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();
        }
Ejemplo n.º 6
0
        protected override void Configure()
        {
            _container = new WinRTContainer();
            _container.RegisterWinRTServices();

            _eventAggregator = _container.GetInstance <IEventAggregator>();
        }
Ejemplo n.º 7
0
        public void RegisterFrame(Frame frame)
        {
            MarkedUp.AnalyticClient.RegisterNavigationFrame(frame);

            container.RegisterNavigationService(frame);

            navigationService = container.GetInstance <INavigationService>();
        }
Ejemplo n.º 8
0
        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();
        }
Ejemplo n.º 9
0
        protected override void Configure()
        {
            _container = new WinRTContainer();
            _container.RegisterWinRTServices();

            //_container.PerRequest<ShellViewModel>();

            _eventAggregator = _container.GetInstance <IEventAggregator>();
        }
Ejemplo n.º 10
0
        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();
            }
        }
Ejemplo n.º 11
0
        public void RegisterFrame(Frame frame)
        {
            container.RegisterNavigationService(frame);

            navigationService = container.GetInstance <INavigationService>();

            navigationService.Navigated += (s, e) => NotifyOfPropertyChange(nameof(CanGoBack));

            navigationService.NavigateToViewModel <MenuViewModel>();
        }
Ejemplo n.º 12
0
        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>();
        }
Ejemplo n.º 13
0
        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();
            }
        }
Ejemplo n.º 14
0
 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>();
        }
Ejemplo n.º 16
0
        protected override void Configure()
        {
            _container = new WinRTContainer();
            _container.RegisterWinRTServices();

            _container
                .PerRequest<ShellViewModel>()
                .PerRequest<DeviceViewModel>();

            _eventAggregator = _container.GetInstance<IEventAggregator>();
        }
Ejemplo n.º 17
0
        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>();
        }
Ejemplo n.º 19
0
        /// <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>();
        }
Ejemplo n.º 20
0
        public MainPageView()
        {
            this.InitializeComponent();

            NavigationCacheMode = NavigationCacheMode.Required;

            WinRTContainer container = (Application.Current as App).container;

            IEventAggregator eventAggregator = container.GetInstance <IEventAggregator>();

            eventAggregator.Subscribe(this);
        }
Ejemplo n.º 21
0
        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();
                }
            };
        }
Ejemplo n.º 22
0
        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;
        }
Ejemplo n.º 23
0
        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>();
        }
Ejemplo n.º 24
0
        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();
                }
            });
        }
Ejemplo n.º 25
0
        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>();
        }
Ejemplo n.º 26
0
        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>();
        }
Ejemplo n.º 27
0
        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>();
        }
Ejemplo n.º 28
0
 protected override object GetInstance(Type service, string key)
 {
     return _container.GetInstance(service, key);
 }