/// <summary>
        /// Identify, load and configure all instances of <see cref="IStorageMechanism"/> and <see cref="IStorageHandler"/> 
        /// that are defined in the assembly associated with this bootstrapper.
        /// </summary>
        /// <param name="phoneContainer">The currently configured <see cref="PhoneContainer"/>.</param>
        /// <remarks>
        /// Caliburn Micro will automatically load storage handlers and storage mechanisms from the assemblies configured
        /// in <see cref="AssemblySource.Instance"/> when <see cref="PhoneContainer.RegisterPhoneServices"/> is first invoked.
        /// Since the purpose of this bootstrapper is to allow the delayed loading of assemblies, it makes sense to locate
        /// the storage handlers alongside the view models in the same assembly. 
        /// </remarks>
        private void ConfigureStorageMechanismsAndWorkers(SimpleContainer phoneContainer) {
            var coordinator = (StorageCoordinator) (phoneContainer.GetInstance(typeof (StorageCoordinator), null));
            var assembly = GetType().Assembly;

            phoneContainer.AllTypesOf<IStorageMechanism>(assembly);
            phoneContainer.AllTypesOf<IStorageHandler>(assembly);

            phoneContainer.GetAllInstances(typeof (IStorageMechanism)).
                           Where(m => ReferenceEquals(m.GetType().Assembly, assembly)).
                           Apply(m => coordinator.AddStorageMechanism((IStorageMechanism) m));

            phoneContainer.GetAllInstances(typeof (IStorageHandler)).
                           Where(h => ReferenceEquals(h.GetType().Assembly, assembly)).
                           Apply(h => coordinator.AddStorageHandler((IStorageHandler) h));
        }
        /// <summary>
        /// Identify, load and configure all instances of <see cref="IStorageMechanism"/> and <see cref="IStorageHandler"/>
        /// that are defined in the assembly associated with this bootstrapper.
        /// </summary>
        /// <param name="phoneContainer">The currently configured <see cref="PhoneContainer"/>.</param>
        /// <remarks>
        /// Caliburn Micro will automatically load storage handlers and storage mechanisms from the assemblies configured
        /// in <see cref="AssemblySource.Instance"/> when <see cref="PhoneContainer.RegisterPhoneServices"/> is first invoked.
        /// Since the purpose of this bootstrapper is to allow the delayed loading of assemblies, it makes sense to locate
        /// the storage handlers alongside the view models in the same assembly.
        /// </remarks>
        private void ConfigureStorageMechanismsAndWorkers(SimpleContainer phoneContainer)
        {
            var coordinator = (StorageCoordinator)(phoneContainer.GetInstance(typeof(StorageCoordinator), null));
            var assembly    = GetType().Assembly;

            phoneContainer.AllTypesOf <IStorageMechanism>(assembly);
            phoneContainer.AllTypesOf <IStorageHandler>(assembly);

            phoneContainer.GetAllInstances(typeof(IStorageMechanism)).
            Where(m => ReferenceEquals(m.GetType().Assembly, assembly)).
            Apply(m => coordinator.AddStorageMechanism((IStorageMechanism)m));

            phoneContainer.GetAllInstances(typeof(IStorageHandler)).
            Where(h => ReferenceEquals(h.GetType().Assembly, assembly)).
            Apply(h => coordinator.AddStorageHandler((IStorageHandler)h));
        }
Exemple #3
0
        public App(SimpleContainer container)
        {
            InitializeComponent();

            this._container = container;

            // TODO: Register additional viewmodels and services
            _container
            // automatically register all viewmodels
            .AllTypesOf <BaseScreen>(GetType().GetTypeInfo().Assembly, ContainerRegistrationKind.PerRequest)
            // alternatively, register each viewmodel individually
            //.PerRequest<MainViewModel>()

            // register services
            .Singleton <IEventAggregator, EventAggregator>()
            ;

            // setup root page as a navigation page
            PrepareViewFirst();

            // navigate to main view
            container.GetInstance <INavigationService>()
            .For <MainViewModel>()
            .Navigate(false);
        }
Exemple #4
0
        protected override void Configure()
        {
            container = new SimpleContainer();

            container.Singleton <IWindowManager, WindowManager>();
            container.Singleton <IEventAggregator, EventAggregator>();
            container.AllTypesOf <IMatchSerializer>(Assembly.GetExecutingAssembly());
            container.Singleton <IMatchManager, MatchManager>();
            container.Singleton <IReportGenerationQueueManager, ReportGenerationQueueManager>();
            container.Singleton <IShell, ShellViewModel>();
            container.Singleton <IDialogCoordinator, DialogCoordinator>();
            container.AllTypesOf <IResultViewTabItem>(Assembly.GetExecutingAssembly());
            // Report generation
            container.Singleton <IReportGenerator, DefaultReportGenerator>("default");
            container.Singleton <IReportGenerator, CustomizedReportGenerator>("customized");
            // Report rendering
            container.RegisterPerRequest(typeof(IReportRenderer), "PDF", typeof(PdfRenderer));
        }
Exemple #5
0
        public App(SimpleContainer container)
        {
            InitializeComponent();

            this._container = container;

            // TODO: Register additional viewmodels and services
            _container
            // automatically register all viewmodels
            .AllTypesOf <BaseScreen>(GetType().GetTypeInfo().Assembly, ContainerRegistrationKind.PerRequest)
            // alternatively, register each viewmodel individually
            //.PerRequest<MainViewModel>()

            // register services
            .Singleton <IEventAggregator, EventAggregator>();

            // setup root page as a navigation page
            PrepareViewFirst();
            if (!container.HasHandler(typeof(LoginViewModel), null))
            {
                container
                .PerRequest <LoginViewModel>()
                .PerRequest <DeliveryDetailViewModel>()
                .PerRequest <MainViewModel>()
                .PerRequest <SignUpViewModel>();
            }
            // navigate to main view
            var myValue = Preferences.Get("IsLogged", false);

            if (!myValue)
            {
                container.GetInstance <INavigationService>()
                .For <LoginViewModel>()
                .Navigate(false);
            }
            else
            {
                container.GetInstance <INavigationService>()
                .For <MainViewModel>()
                .Navigate(false);
            }
        }