Ejemplo n.º 1
0
        /// <summary>
        /// Configure all singleton and objects that
        /// need to be stored in the container for
        /// IoC and dependency injection.  This will allow
        /// you to put in the constructor an object that is
        /// stored within the container and it will automagically
        /// be retreived from the container without having to
        /// pass value to the constructor.
        /// </summary>
        protected override void Configure()
        {
            // Found at https://github.com/gblmarquez/mui-sample-chat/blob/master/src/MuiChat.App/Bootstrapper.cs
            // Allows the CaliburnContentLoader to find the viewmodel based off the view string given
            // Used with ModernUI to navigate between views.
            ViewLocator.NameTransformer.AddRule(
                @"(?<nsbefore>([A-Za-z_]\w*\.)*)?(?<nsvm>ViewModels\.)(?<nsafter>([A-Za-z_]\w*\.)*)(?<basename>[A-Za-z_]\w*)(?<suffix>ViewModel$)",
                @"${nsbefore}Views.${nsafter}${basename}View",
                @"(([A-Za-z_]\w*\.)*)?ViewModels\.([A-Za-z_]\w*\.)*[A-Za-z_]\w*ViewModel$"
                );

            _container = new SimpleContainer();

            base.Configure();

            // Set the localization of the app to the culture of the environment
            //LocalizeDictionary.Instance.Culture = CultureInfo.CurrentCulture;
            //LocalizeDictionary.Instance.SetCurrentThreadCulture = true;
            //LocalizeDictionary.Instance.Culture = CultureInfo.GetCultureInfo("en-US");
            //Application.Current.Dispatcher.BeginInvoke(new System.Action(() => LocalizeDictionary.Instance.Culture = CultureInfo.CurrentCulture);

            ContainerExtensions.Singleton <IWindowManager, WindowManager>(_container);

            ContainerExtensions.Singleton <IEventAggregator, EventAggregator>(_container);

            ContainerExtensions.Singleton <IShellViewModel, ShellViewModel>(_container);

            // Singleton AdcpConnection
            ContainerExtensions.Singleton <AdcpConnection, AdcpConnection>(_container);

            // Singleton ProjectManager
            ContainerExtensions.Singleton <PulseManager, PulseManager>(_container);

            // Singleton DataFormatViewModel
            ContainerExtensions.Singleton <DataFormatViewModel, DataFormatViewModel>(_container);

            // Register the PlaybackViewModel
            ContainerExtensions.Singleton <PlaybackViewModel, PlaybackViewModel>(_container);

            // Singleton MainModernFrameViewModel
            ContainerExtensions.PerRequest <NavBarViewModel, NavBarViewModel>(_container);

            // Register the HomeViewModel
            ContainerExtensions.Singleton <HomeViewModel, HomeViewModel>(_container);

            // Register the TerminalViewModel
            //ContainerExtensions.Singleton<TerminalViewModel, TerminalViewModel>(_container);

            // Register the ViewDataBaseViewModel
            ContainerExtensions.Singleton <ViewDataBaseViewModel, ViewDataBaseViewModel>(_container);

            // Register the ValidationTestViewModel
            ContainerExtensions.Singleton <ValidationTestViewModel, ValidationTestViewModel>(_container);

            // Register the CompassCalViewModel
            ContainerExtensions.Singleton <CompassCalViewModel, CompassCalViewModel>(_container);

            // Register the ViewDataBaseGraphicalViewModel
            ContainerExtensions.Singleton <ViewDataBaseGraphicalViewModel, ViewDataBaseGraphicalViewModel>(_container);

            // Register the ViewDataBaseTextViewModel
            ContainerExtensions.Singleton <ViewDataBaseTextViewModel, ViewDataBaseTextViewModel>(_container);

            // Register the ViewDataBaseDvlViewModel
            ContainerExtensions.Singleton <ViewDataBaseDvlViewModel, ViewDataBaseDvlViewModel>(_container);

            // Register the ViewDataBaseTextViewModel
            ContainerExtensions.PerRequest <ViewDataTextEnsembleViewModel, ViewDataTextEnsembleViewModel>(_container);

            // Register the ScreenDataBaseViewModel
            ContainerExtensions.Singleton <ScreenDataBaseViewModel, ScreenDataBaseViewModel>(_container);

            // Register the AveragingBaseViewModel
            ContainerExtensions.Singleton <AveragingBaseViewModel, AveragingBaseViewModel>(_container);

            // Register the ValidationTestBaseViewModel
            ContainerExtensions.Singleton <ValidationTestBaseViewModel, ValidationTestBaseViewModel>(_container);

            // Register the DownloadDataViewModel
            ContainerExtensions.Singleton <DownloadDataViewModel, DownloadDataViewModel>(_container);

            // Register the UpdateFirmwareViewModel
            ContainerExtensions.Singleton <UpdateFirmwareViewModel, UpdateFirmwareViewModel>(_container);

            // Register the CompassUtilityViewModel
            ContainerExtensions.Singleton <CompassUtilityViewModel, CompassUtilityViewModel>(_container);

            // Register the CompassUtilityViewModel
            ContainerExtensions.Singleton <ViewDataBaseBackscatterViewModel, ViewDataBaseBackscatterViewModel>(_container);

            // Register the TerminalAdcpViewModel
            //ContainerExtensions.Singleton<TerminalAdcpViewModel, TerminalAdcpViewModel>(_container);

            // Register the TerminalGpsViewModel
            //ContainerExtensions.Singleton<TerminalNavViewModel, TerminalNavViewModel>(_container);

            // Register the AboutViewModel
            ContainerExtensions.Singleton <AboutViewModel, AboutViewModel>(_container);

            // Register the ExportDataViewModel
            ContainerExtensions.PerRequest <ExportDataViewModel, ExportDataViewModel>(_container);

            // Register the ModeViewModel
            ContainerExtensions.PerRequest <ModeViewModel, ModeViewModel>(_container);

            // Register the ProjectViewModel
            ContainerExtensions.PerRequest <ProjectViewModel, ProjectViewModel>(_container);

            // Register the NewProjectViewModel
            ContainerExtensions.PerRequest <NewProjectViewModel, NewProjectViewModel>(_container);

            // Register the SerialNumberGeneratorViewModel
            ContainerExtensions.PerRequest <SerialNumberGeneratorViewModel, SerialNumberGeneratorViewModel>(_container);

            // Register the CommunicationViewModel
            ContainerExtensions.PerRequest <CommunicationViewModel, CommunicationViewModel>(_container);

            // Register the StorageViewModel
            ContainerExtensions.PerRequest <StorageViewModel, StorageViewModel>(_container);

            // Register the LoadProjectsViewModel
            ContainerExtensions.Singleton <LoadProjectsViewModel, LoadProjectsViewModel>(_container);

            // Register the LoadProjectsViewModel
            ContainerExtensions.PerRequest <AdcpConfigurationViewModel, AdcpConfigurationViewModel>(_container);

            // Register the BottomTrackOnViewModel
            ContainerExtensions.PerRequest <BottomTrackOnViewModel, BottomTrackOnViewModel>(_container);

            // Register the BinsViewModel
            ContainerExtensions.PerRequest <BinsViewModel, BinsViewModel>(_container);

            // Register the PingTimingViewModel
            ContainerExtensions.PerRequest <PingTimingViewModel, PingTimingViewModel>(_container);

            // Register the FrequencyViewModel
            ContainerExtensions.PerRequest <FrequencyViewModel, FrequencyViewModel>(_container);

            // Register the BroadbandModeViewModel
            ContainerExtensions.PerRequest <BroadbandModeViewModel, BroadbandModeViewModel>(_container);

            // Register the VesselMountViewModel
            ContainerExtensions.Singleton <VesselMountViewModel, VesselMountViewModel>(_container);

            // Register the SaveAdcpConfigurationViewModel
            ContainerExtensions.PerRequest <SaveAdcpConfigurationViewModel, SaveAdcpConfigurationViewModel>(_container);

            // Register the SalinityViewModel
            ContainerExtensions.PerRequest <SalinityViewModel, SalinityViewModel>(_container);

            // Register the TimeViewModel
            ContainerExtensions.PerRequest <TimeViewModel, TimeViewModel>(_container);

            // Register the EnsembleIntervalViewModel
            ContainerExtensions.PerRequest <EnsembleIntervalViewModel, EnsembleIntervalViewModel>(_container);

            // Register the SimpleCompassCalViewModel
            ContainerExtensions.PerRequest <SimpleCompassCalViewModel, SimpleCompassCalViewModel>(_container);

            // Register the SimpleCompassCalWizardViewModel
            ContainerExtensions.PerRequest <SimpleCompassCalWizardViewModel, SimpleCompassCalWizardViewModel>(_container);

            // Register the ZeroPressureSensorViewModel
            ContainerExtensions.PerRequest <ZeroPressureSensorViewModel, ZeroPressureSensorViewModel>(_container);

            // Register the DeployAdcpViewModel
            ContainerExtensions.PerRequest <DeployAdcpViewModel, DeployAdcpViewModel>(_container);

            // Register the ScanAdcpViewModel
            ContainerExtensions.PerRequest <ScanAdcpViewModel, ScanAdcpViewModel>(_container);

            // Register the AdcpUtilitiesViewModel
            ContainerExtensions.PerRequest <AdcpUtilitiesViewModel, AdcpUtilitiesViewModel>(_container);

            // Register the BurstModeViewModel
            ContainerExtensions.PerRequest <BurstModeViewModel, BurstModeViewModel>(_container);

            // Register the AdcpPredicitionModelViewModel
            ContainerExtensions.PerRequest <AdcpPredictionModelViewModel, AdcpPredictionModelViewModel>(_container);

            // Register the SelectPlaybackViewModel
            ContainerExtensions.PerRequest <SelectPlaybackViewModel, SelectPlaybackViewModel>(_container);

            // Register the DvlSetupViewModel
            ContainerExtensions.PerRequest <DvlSetupViewModel, DvlSetupViewModel>(_container);

            // Register the RtiCompassCalViewModel
            ContainerExtensions.Singleton <RtiCompassCalViewModel, RtiCompassCalViewModel>(_container);

            // Register the DiagnosticsBaseViewModel
            ContainerExtensions.Singleton <DiagnosticsBaseViewModel, DiagnosticsBaseViewModel>(_container);

            // Register the DataOutputViewModel
            ContainerExtensions.Singleton <DataOutputViewModel, DataOutputViewModel>(_container);

            // Register the WpMagDirOutputViewModel
            ContainerExtensions.Singleton <WpMagDirOutputViewModel, WpMagDirOutputViewModel>(_container);

            // Register the ViewDataBaseProfile3DViewModel
            ContainerExtensions.Singleton <ViewDataBaseProfile3DViewModel, ViewDataBaseProfile3DViewModel>(_container);

            // Register the BaseDataOutputViewModel
            ContainerExtensions.Singleton <BaseDataOutputViewModel, BaseDataOutputViewModel>(_container);
        }