public void ConfigurationOfContainer_WithInteractions_CanBeValidatedWithoutWarnings(Bootstrapper bootstrapper) { EnsureApplicationResources(); var container = new Container(); var windowResolver = new TestWindowResolver(container); var windowRegistry = new WindowRegistry(windowResolver); bootstrapper.ConfigureContainer(container, windowRegistry); bootstrapper.RegisterInteractions(windowRegistry); LoggingHelper.InitConsoleLogger("PDFCreator-Test", LoggingLevel.Off); var settingsHelper = container.GetInstance <ISettingsManager>(); settingsHelper.LoadAllSettings(); container.Verify(VerificationOption.VerifyOnly); var result = Analyzer.Analyze(container) .Where(x => x.Severity > DiagnosticSeverity.Information) .Where(x => (x.DiagnosticType != DiagnosticType.LifestyleMismatch) || !_lifestyleMismatchAcceptableClasses.Contains(x.ServiceType)) .ToList(); var message = ""; foreach (var diagnosticResult in result) { message += $"{diagnosticResult.Severity} | {diagnosticResult.DiagnosticType}: {diagnosticResult.Description} {Environment.NewLine}"; } Assert.IsFalse(result.Any(), message); }
private static int StartApplication(string[] args, Func <Bootstrapper> getBootstrapperFunc) { Application.EnableVisualStyles(); Thread.CurrentThread.Name = "ProgramThread"; InitializeLogging(); Logger.Debug("Starting PDFCreator"); AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; var bootstrapper = getBootstrapperFunc(); var container = new Container(); var windowResolver = new SimpleInjectorWindowResolver(container); var windowRegistry = new WindowRegistry(windowResolver); bootstrapper.ConfigureContainer(container, windowRegistry); bootstrapper.RegisterInteractions(windowRegistry); container.Verify(VerificationOption.VerifyOnly); var resolver = new SimpleInjectorAppStartResolver(container); var appStartFactory = new AppStartFactory(resolver); var appStart = appStartFactory.CreateApplicationStart(args); var app = new App(appStart); app.DispatcherUnhandledException += Application_DispatcherUnhandledException; return(app.Run()); }
public void RegisterInteractions(WindowRegistry windowRegistry) { windowRegistry.RegisterInteraction(typeof(ApplicationSettingsInteraction), typeof(ApplicationSettingsWindow)); windowRegistry.RegisterInteraction(typeof(InputInteraction), typeof(InputBoxWindow)); windowRegistry.RegisterInteraction(typeof(MessageInteraction), typeof(MessageWindow)); windowRegistry.RegisterInteraction(typeof(MainWindowInteraction), typeof(MainWindow)); windowRegistry.RegisterInteraction(typeof(PlusHintInteraction), typeof(PlusHintWindow)); windowRegistry.RegisterInteraction(typeof(ManagePrintJobsInteraction), typeof(ManagePrintJobsWindow)); windowRegistry.RegisterInteraction(typeof(PrintJobInteraction), typeof(PrintJobWindow)); windowRegistry.RegisterInteraction(typeof(ProfileSettingsInteraction), typeof(ProfileSettingsWindow)); windowRegistry.RegisterInteraction(typeof(ConversionProgressInteraction), typeof(ConversionProgressWindow)); windowRegistry.RegisterInteraction(typeof(EncryptionPasswordInteraction), typeof(EncryptionPasswordsWindow)); windowRegistry.RegisterInteraction(typeof(AboutWindowInteraction), typeof(AboutWindow)); windowRegistry.RegisterInteraction(typeof(EditEmailTextInteraction), typeof(EditEmailTextWindow)); windowRegistry.RegisterInteraction(typeof(ProfileProblemsInteraction), typeof(DefectiveProfilesWindow)); windowRegistry.RegisterInteraction(typeof(UpdateDownloadInteraction), typeof(UpdateDownloadWindow)); windowRegistry.RegisterInteraction(typeof(RecommendPdfArchitectInteraction), typeof(RecommendPdfArchitectWindow)); windowRegistry.RegisterInteraction(typeof(SignaturePasswordInteraction), typeof(SignaturePasswordWindow)); windowRegistry.RegisterInteraction(typeof(PasswordInteraction), typeof(PasswordWindow)); windowRegistry.RegisterInteraction(typeof(WelcomeInteraction), typeof(WelcomeWindow)); windowRegistry.RegisterInteraction(typeof(OfflineActivationInteraction), typeof(OfflineActivationWindow)); windowRegistry.RegisterInteraction(typeof(LicenseInteraction), typeof(LicenseWindow)); windowRegistry.RegisterInteraction(typeof(DropboxInteraction), typeof(DropboxAuthenticationWindow)); windowRegistry.RegisterInteraction(typeof(UpdateAvailableInteraction), typeof(UpdateAvailableWindow)); windowRegistry.RegisterInteraction(typeof(StoreLicenseForAllUsersInteraction), typeof(StoreLicenseForAllUsersWindow)); }
public void ConfigureContainer(Container container, WindowRegistry windowRegistry) { container.Options.SuppressLifestyleMismatchVerification = true; RegisterActivationHelper(container); container.RegisterSingleton(() => new ApplicationNameProvider(EditionName)); container.RegisterSingleton(() => new LicenseOptionProvider(HideLicensing)); container.RegisterSingleton(() => ButtonDisplayOptions); container.RegisterSingleton(() => new DropboxAppData(Data.Decrypt("r4IH27xLkSb2FWkNUcPfwA=="), "https://www.dropbox.com/1/oauth2/redirect_receiver")); if (ShowWelcomeWindow) { container.Register <WelcomeCommand, ShowWelcomeWindowCommand>(); } else { container.Register <WelcomeCommand, DisabledWelcomeWindowCommand>(); } var regPath = @"Software\pdfforge\PDFCreator"; container.RegisterSingleton <IInstallationPathProvider>(() => new InstallationPathProvider(regPath, regPath + @"\Settings", "{0001B4FD-9EA3-4D90-A79E-FD14BA3AB01D}")); _workflowFactory = new WorkflowFactory(container); container.Register <ConversionWorkflow>(); // Workflow is registered so all dependencies can be verified in test container.Register <IWorkflowFactory>(() => _workflowFactory); // Here come workflow depedent registrations! RegisterWorkflowDependent <IErrorNotifier, ErrorNotifierInteractive, ErrorNotifierAutosave>(container); RegisterWorkflowDependent <IProcessingPasswordsProvider, InteractiveProcessingPasswordsProvider, DefaultProcessingPasswordsProvider>(container); RegisterWorkflowDependent <IFtpPasswordProvider, InteractiveFtpPasswordProvider, FtpPasswordProvider>(container); RegisterWorkflowDependent <ISmtpPasswordProvider, InteractiveSmtpPasswordProvider, SmtpPasswordProvider>(container); RegisterWorkflowDependent <ITargetFileNameComposer, InteractiveTargetFileNameComposer, AutosaveTargetFileNameComposer>(container); RegisterWorkflowDependent <IRecommendArchitect, InteractiveRecommendArchitect, AutosaveRecommendArchitect>(container); RegisterWorkflowDependent <IConversionProgress, InteractiveConversionProgress, AutosaveConversionProgress>(container); RegisterWorkflowDependent <IOutputFileMover, InteractiveOutputFileMover, AutosaveOutputFileMover>(container); container.RegisterSingleton <IInteractionInvoker>(() => new InteractionInvoker(windowRegistry)); container.Register <ISoundPlayer, SoundPlayer>(); container.Register <ISmtpTest, SmtpTestEmailAssistant>(); container.Register <IClientTestEmail, ClientTestEmail>(); container.Register <IActionManager, ActionManager>(); container.Register <IJobPrinter, GhostScriptPrinter>(); container.Register <IJobDataUpdater, JobDataUpdater>(); container.Register <IPageNumberCalculator, PageNumberCalculator>(); container.Register <IOutputFilenameComposer, OutputFilenameComposer>(); container.Register <IJobRunner, JobRunner>(); container.Register <IConverterFactory, ConverterFactory>(); container.Register <IPsConverterFactory, GhostscriptConverterFactory>(); container.Register <IJobCleanUp, JobCleanUp>(); container.Register <ISystemPrinterProvider, SystemPrinterProvider>(); container.Register <IDirectConversionProvider, DirectConversionProvider>(); container.Register <IDirectConversionHelper, DirectConversionHelper>(); container.RegisterSingleton <IFileConversionHandler, FileConversionHandler>(); container.Register <IPrintFileHelper, PrintFileAssistant>(); container.Register <IUacAssistant, UacAssistant>(); container.Register <ITestPageHelper, TestPageHelper>(); container.RegisterSingleton <PdfArchitectCheck>(); container.RegisterSingleton <IPdfArchitectCheck, CachedPdfArchitectCheck>(); container.Register <IGhostscriptDiscovery, GhostscriptDiscovery>(); container.RegisterSingleton <IRegistry, RegistryWrap>(); container.RegisterSingleton <IFile, FileWrap>(); container.RegisterSingleton <IDirectory, DirectoryWrap>(); container.RegisterSingleton <IPath, PathWrap>(); container.RegisterSingleton <IPathSafe, PathWrapSafe>(); container.RegisterSingleton <IPathUtil, PathUtil>(); container.RegisterSingleton <IEnvironment, EnvironmentWrap>(); container.RegisterSingleton <IProcessStarter, ProcessStarter>(); container.RegisterSingleton <IDateTimeProvider, DateTimeProvider>(); container.RegisterSingleton <IAssemblyHelper, AssemblyHelper>(); container.Register <IOsHelper, OsHelper>(); container.Register <IFontHelper, FontHelper>(); container.Register <IOpenFileInteractionHelper, OpenFileInteractionHelper>(); container.Register <IPDFCreatorNameProvider, PDFCreatorNameProvider>(); container.Register <IPdfProcessor, ITextPdfProcessor>(); container.RegisterSingleton <IJobInfoQueueManager, JobInfoQueueManager>(); container.Register <IJobInfoQueue, JobInfoQueue>(Lifestyle.Singleton); container.Register <IThreadManager, ThreadManager>(Lifestyle.Singleton); container.Register <IPipeServerManager, PipeServerManager>(Lifestyle.Singleton); container.RegisterSingleton <IPipeMessageHandler, NewPipeJobHandler>(); container.Register <IVersionHelper, VersionHelper>(); container.Register <ITerminalServerDetection, TerminalServerDetection>(); container.Register <IRepairSpoolFolderAssistant, RepairSpoolFolderAssistant>(); container.Register <ISpoolFolderAccess, SpoolFolderAccess>(); container.Register <IShellExecuteHelper, ShellExecuteHelper>(); container.RegisterSingleton <IPrinterPortReader, PrinterPortReader>(); RegisterPrinterHelper(container); container.Register <IFileAssoc, FileAssoc>(); container.RegisterSingleton <IHashUtil, HashUtil>(); container.Register <ISignaturePasswordCheck, SignaturePasswordCheck>(); container.Register <IWelcomeSettingsHelper, WelcomeSettingsHelper>(); container.Register <IEmailClientFactory, EmailClientFactory>(); container.Register <IProfileChecker, ProfileChecker>(); container.Register <IPrinterActionsAssistant, PrinterActionsAssistant>(); container.Register <IRepairPrinterAssistant, RepairPrinterAssistant>(); container.Register <IDispatcher, DispatcherWrapper>(); container.RegisterSingleton <ILanguageDetector, LanguageDetector>(); container.RegisterSingleton <ISettingsMover, SettingsMover>(); container.RegisterSingleton <IRegistryUtility, RegistryUtility>(); container.Register <IMaybePipedApplicationStarter, MaybePipedApplicationStarter>(); container.Register <ITokenReplacerFactory, TokenReplacerFactory>(); container.RegisterSingleton <ISettingsLoader, SettingsLoader>(); container.Register <IIniSettingsAssistant, IniSettingsAssistant>(); container.Register <IIniSettingsLoader, IniSettingsLoader>(); container.Register <IDataStorageFactory, DataStorageFactory>(); container.RegisterSingleton <IJobInfoManager, JobInfoManager>(); container.Register <IStaticPropertiesHack, StaticPropertiesHack>(); container.RegisterSingleton <IMainWindowThreadLauncher, MainWindowThreadLauncher>(); container.Register <IManagePrintJobExceptionHandler, ManagePrintJobExceptionHandler>(); container.Register <IPdfCreatorCleanUp, PdfCreatorCleanUp>(); container.Register <IMailSignatureHelper, MailSignatureHelper>(); container.Register <ISpooledJobFinder, SpooledJobFinder>(); container.Register <IFtpConnectionFactory, FtpConnectionFactory>(); container.Register <IScriptActionHelper, ScriptAction>(); container.Register <IJobBuilder, JobBuilder>(); container.Register <IJobFinishedHandler, JobFinishedHandler>(); container.Register <IDropboxService, DropboxService>(); container.Register <IWinInetHelper, WinInetHelper>(); container.RegisterSingleton <ITitleReplacerProvider, SettingsTitleReplacerProvider>(); RegisterFolderProvider(container); RegisterUserGuideHelper(container); RegisterTranslator(container); RegisterSettingsHelper(container); RegisterStartupConditions(container); RegisterActions(container); RegisterActionChecks(container); RegisterFileNameQuery(container); RegisterUpdateAssistant(container); RegisterUserTokenExtractor(container); RegisterPlusHintHelper(container); container.RegisterSingleton(BuildCustomization); }