Example #1
0
        public static void Main()
        {
            var applicationConfig = ApplicationConfigBuilder.
                                    Create()
                                    //.WithoutAsyncAssemblyLoading()
                                    // Make sure the bootstrapper knows where to find it's DLL files
                                    .WithScanDirectories(
                ScanLocations.GenerateScanDirectories(
#if NET471
                    "net471",
#else
                    "netcoreapp3.0",
#endif
                    "Application.Demo.Addon",
                    "Application.Demo.MetroAddon",
                    "Application.Demo.OverlayAddon").ToArray()
                )
                                    .WithApplicationName("Application.Demo")
                                    .WithMutex("f32dbad8-9904-473e-86e2-19275c2d06a5")
                                    // Enable CaliburnMicro
                                    .WithCaliburnMicro()
                                    .WithoutCopyOfEmbeddedAssemblies()
#if NET471
                                    .WithoutCopyOfAssembliesToProbingPath()
#endif
                                    //.WithoutStrictChecking()
                                    // Load the Application.Demo.* assemblies
                                    .WithAssemblyPatterns("Application.Demo.*").BuildApplicationConfig();

            Start(applicationConfig);
        }
Example #2
0
        /// <inheritdoc />
        protected override void Load(ContainerBuilder builder)
        {
            // Specify the directories for the translations manually
            builder.Register(context => LanguageConfigBuilder.Create()
                             .WithSpecificDirectories(ScanLocations.GenerateScanDirectories(
#if NET471
                                                          "net471",
#else
                                                          "netcoreapp3.1",
#endif
                                                          "Application.Demo.Addon",
                                                          "Application.Demo.MetroAddon",
                                                          "Application.Demo.OverlayAddon").ToArray()
                                                      )
                             .BuildLanguageConfig())
            .As <LanguageConfig>()
            .SingleInstance();

            builder
            .Register(c => Language <ICoreTranslations> .Create())
            .As <ICoreTranslations>()
            .As <IErrorTranslations>()
            .As <ILanguage>()
            .SingleInstance();

            builder
            .Register(c => IniSection <IDemoConfiguration> .Create())
            .As <IDemoConfiguration>()
            .As <IIniSection>()
            .SingleInstance();

            builder
            .Register(c => Language <IDemoConfigTranslations> .Create())
            .As <IDemoConfigTranslations>()
            .As <ILanguage>()
            .SingleInstance();
            builder
            .Register(c => Language <IContextMenuTranslations> .Create())
            .As <IContextMenuTranslations>()
            .As <ILanguage>()
            .SingleInstance();

            builder
            .Register(c => Language <IMenuTranslations> .Create())
            .As <IMenuTranslations>()
            .As <ILanguage>()
            .SingleInstance();

            builder
            .Register(c => Language <IToastTranslations> .Create())
            .As <IToastTranslations>()
            .As <ILanguage>()
            .SingleInstance();

            builder
            .Register(c => Language <IValidationErrors> .Create())
            .As <IValidationErrors>()
            .As <ILanguage>()
            .SingleInstance();

            builder
            .Register(c => Language <IWizardTranslations> .Create())
            .As <IWizardTranslations>()
            .As <ILanguage>()
            .SingleInstance();

            builder.RegisterType <DemoTrayIconViewModel>()
            .As <ITrayIconViewModel>()
            .WithAttributeFiltering()
            .SingleInstance();
            builder.RegisterType <AuthenticationProvider>()
            .As <IAuthenticationProvider>()
            .SingleInstance();
            builder.RegisterType <NotifyOfStartupReady>()
            .As <IService>()
            .SingleInstance();
            builder.RegisterType <SimpleVersionProvider>()
            .As <IVersionProvider>()
            .SingleInstance();

            // All IMenuItem with the context they belong to
            builder.RegisterAssemblyTypes(ThisAssembly)
            .AssignableTo <IMenuItem>()
            .As <IMenuItem>()
            .SingleInstance();

            // All config screens
            builder.RegisterAssemblyTypes(ThisAssembly)
            .AssignableTo <IConfigScreen>()
            .As <IConfigScreen>()
            .AsSelf()
            .SingleInstance();

            // All wizard screens
            builder.RegisterAssemblyTypes(ThisAssembly)
            .AssignableTo <IWizardScreen>()
            .As <IWizardScreen>()
            .SingleInstance();

            builder.RegisterType <ConfigViewModel>()
            .AsSelf()
            .SingleInstance();

            // View models
            builder.RegisterType <WindowWithMenuViewModel>()
            .AsSelf()
            .WithAttributeFiltering()
            .SingleInstance();

            builder.RegisterType <StartupReadyToastViewModel>()
            .AsSelf()
            .SingleInstance();

            builder.RegisterType <WizardExampleViewModel>()
            .AsSelf()
            .SingleInstance();

            // Not a single instance
            builder.RegisterType <ToastExampleViewModel>()
            .AsSelf();

            builder.RegisterType <AllowAllKeyInputEventHandler>()
            .As <IKeyboardEventHandler>()
            .SingleInstance();

            base.Load(builder);
        }