コード例 #1
0
        public void ConfigureContainer(Container container)
        {
            container.Options.SuppressLifestyleMismatchVerification = true;

            RegisterActivationHelper(container);
            container.RegisterSingleton(() => new ApplicationNameProvider(EditionName));
            container.RegisterSingleton <IHightlightColorRegistration>(() => new HightlightColorRegistration(EditionHighlightColor));
            container.RegisterSingleton(() => new LicenseOptionProvider(HideLicensing));
            container.RegisterSingleton(() => ShowOnlyForPlusAndBusinessHint);
            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 <AutoSaveWorkflow>();    // Workflow is registered so all dependencies can be verified in test
            container.Register <InteractiveWorkflow>(); // Workflow is registered so all dependencies can be verified in test

            var commandLocator = new CommandLocator(container);

            container.Register <ICommandLocator>(() => commandLocator);

            container.Register <IWorkflowFactory>(() => _workflowFactory);

            container.Register <IOutputFileMover, AutosaveOutputFileMover>();

            container.Register <ITargetFileNameComposer, AutosaveTargetFileNameComposer>();
            container.Register <IErrorNotifier, ErrorNotifierInteractive>();

            container.RegisterSingleton <IRecommendArchitect, RecommendArchitect>();

            container.RegisterSingleton <IInteractionInvoker, InteractionInvoker>();

            RegisterInteractionRequestPerThread(container);

            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.Register <ProfileRemoveCommand>();
            container.Register <ProfileRenameCommand>();

            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 <IDirectoryHelper, DirectoryHelper>();

            container.RegisterSingleton <IProcessStarter, ProcessStarter>();
            container.RegisterSingleton <IDateTimeProvider, DateTimeProvider>();

            container.RegisterSingleton <IAssemblyHelper>(() => new AssemblyHelper(GetType().Assembly));
            container.Register <IOsHelper, OsHelper>();
            container.Register <IFontHelper, FontHelper>();
            container.Register <IOpenFileInteractionHelper, OpenFileInteractionHelper>();
            container.Register <IPDFCreatorNameProvider, PDFCreatorNameProvider>();

            container.RegisterSingleton <IJobInfoQueueManager, JobInfoQueueManager>();
            container.Register <IJobInfoQueue, JobInfoQueue>(Lifestyle.Singleton);
            container.Register <IThreadManager, ThreadManager>(Lifestyle.Singleton);
            container.Register <IPipeServerManager, PipeServerManager>(Lifestyle.Singleton);
            container.RegisterSingleton <ITranslationUpdater, TranslationUpdater>();
            container.RegisterSingleton <IPipeMessageHandler, NewPipeJobHandler>();

            container.Register <IVersionHelper>(() => new VersionHelper(GetType().Assembly));
            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 <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.Register <IManagePrintJobExceptionHandler, ManagePrintJobExceptionHandler>();
            container.Register <IPdfCreatorCleanUp, PdfCreatorCleanUp>();

            container.Register <ISpooledJobFinder, SpooledJobFinder>();

            container.Register <IFtpConnectionFactory, FtpConnectionFactory>();
            container.Register <IScriptActionHelper, ScriptAction>();

            container.Register <IWorkflowNavigationHelper, WorkflowNavigationHelper>();

            container.Register <IDropboxService, DropboxService>();
            container.Register <IClipboardService, ClipboardService>();
            container.Register <IWinInetHelper, WinInetHelper>();
            container.RegisterSingleton <ITitleReplacerProvider, SettingsTitleReplacerProvider>();

            container.RegisterSingleton <IMainWindowThreadLauncher, MainShellLauncher>();

            container.RegisterSingleton <IGpoSettings>(GetGpoSettings);

            RegisterCurrentSettingsProvider(container);
            RegisterFolderProvider(container);
            RegisterUserGuideHelper(container);
            RegisterTranslator(container);
            RegisterMailSigantureHelper(container);
            RegisterSettingsHelper(container);
            RegisterStartupConditions(container);
            RegisterActions(container);
            RegisterActionChecks(container);
            RegisterFileNameQuery(container);
            RegisterUpdateAssistant(container);
            RegisterJobBuilder(container);
            RegisterInteractiveWorkflowManagerFactory(container);
            RegisterPdfProcessor(container);
            RegisterUserTokenExtractor(container);
            RegisterPlusHintHelper(container);
            container.RegisterSingleton(BuildCustomization);
        }
コード例 #2
0
ファイル: Bootstrapper.cs プロジェクト: wholesky/PDFCreator
        public void RegisterMainApplication(Container container)
        {
            container.Options.SuppressLifestyleMismatchVerification = true;

            RegisterActivationHelper(container);
            container.RegisterSingleton(() => new ApplicationNameProvider(EditionName));
            container.RegisterSingleton <IHightlightColorRegistration>(() => new HightlightColorRegistration(EditionHighlightColor));
            container.RegisterSingleton(() => new LicenseOptionProvider(HideLicensing));
            container.RegisterSingleton(() => EditionHelper);
            container.RegisterSingleton(() => new DropboxAppData(Data.Decrypt(DropboxAppKey.Encrypted_DropboxAppKey), "https://www.dropbox.com/1/oauth2/redirect_receiver"));

            var regPath = @"Software\pdfforge\PDFCreator";

            container.RegisterSingleton <IInstallationPathProvider>(() => new InstallationPathProvider(regPath, regPath + @"\Settings", "{0001B4FD-9EA3-4D90-A79E-FD14BA3AB01D}", RegistryHive.CurrentUser));

            _workflowFactory = new WorkflowFactory(container);
            container.Register <AutoSaveWorkflow>();    // Workflow is registered so all dependencies can be verified in test
            container.Register <InteractiveWorkflow>(); // Workflow is registered so all dependencies can be verified in test

            container.RegisterSingleton <ICommandLocator>(() => new CommandLocator(container));

            container.Register <IWorkflowFactory>(() => _workflowFactory);

            container.Register <IOutputFileMover, AutosaveOutputFileMover>();

            container.Register <ITargetFilePathComposer, TargetFilePathComposer>();
            container.Register <IErrorNotifier, ErrorNotifierInteractive>();
            container.Register <IInteractiveProfileChecker, InteractiveProfileChecker>();

            container.RegisterSingleton <IRecommendArchitect, RecommendArchitect>();
            container.RegisterSingleton <IRecommendArchitectUpgrade, RecommendArchitectUpgrade>();
            container.Register <IStartupActionHandler, StartupActionHandler>();
            container.RegisterSingleton <IInteractionInvoker, InteractionInvoker>();

            RegisterInteractionRequestPerThread(container);

            container.Register <ISoundPlayer, SoundPlayer>();
            container.RegisterSingleton <IWpfTopMostHelper, WpfTopMostHelper>();
            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 <IJobRunner, JobRunner>();
            container.Register <IConverterFactory, ConverterFactory>();
            container.Register <IPsConverterFactory, GhostscriptConverterFactory>();
            container.RegisterSingleton <IUpdateHelper, UpdateHelper>();

            container.Register <IJobCleanUp, JobCleanUp>();

            container.RegisterSingleton <ISystemPrinterProvider, SystemPrinterProvider>();

            container.Register <IDirectConversion, DirectConversion>();
            container.Register <IDirectConversionHelper, DirectConversionHelper>();
            container.Register <IDirectConversionInfFileHelper, DirectConversionInfFileHelper>();
            container.RegisterSingleton <IFileConversionAssistant, FileConversionAssistant>();
            container.Register <IPrintFileHelper, PrintFileAssistant>();
            container.Register <IUacAssistant, UacAssistant>();
            container.Register <ITestPageHelper, TestPageHelper>();
            container.RegisterSingleton <IPdfArchitectCheck, PdfArchitectCheck>();
            container.Register <IGhostscriptDiscovery, GhostscriptDiscovery>();
            container.Register <ProfileRemoveCommand>();
            container.Register <ProfileRenameCommand>();

            container.RegisterSingleton <IRegistry, RegistryWrap>();
            container.RegisterSingleton <IFile, FileWrap>();
            container.RegisterSingleton <IDirectory, DirectoryWrap>();
            container.RegisterSingleton <IPath, PathWrap>();
            container.RegisterSingleton <IPathUtil, PathUtil>();
            container.RegisterSingleton <IEnvironment, EnvironmentWrap>();
            container.RegisterSingleton <IDirectoryHelper, DirectoryHelper>();
            container.RegisterSingleton <IReadableFileSizeFormatter, ReadableReadableFileSizeFormatter>();

            container.RegisterSingleton <IProcessStarter, ProcessStarter>();
            container.RegisterSingleton <IDateTimeProvider, DateTimeProvider>();

            container.RegisterSingleton <IAssemblyHelper>(() => new AssemblyHelper(GetType().Assembly));
            container.RegisterSingleton <IOsHelper, OsHelper>();
            container.Register <IFontHelper, FontHelper>();
            container.Register <IOpenFileInteractionHelper, OpenFileInteractionHelper>();
            container.Register <IPDFCreatorNameProvider, PDFCreatorNameProvider>();
            container.Register <ITokenButtonFunctionProvider, TokenButtonFunctionProvider>();

            container.RegisterSingleton <IJobInfoQueueManager, JobInfoQueueManager>();
            container.Register <IJobInfoQueue, JobInfoQueue>(Lifestyle.Singleton);
            container.Register <IThreadManager, ThreadManager>(Lifestyle.Singleton);
            container.Register <IPipeServerManager, PipeServerManager>(Lifestyle.Singleton);
            container.RegisterSingleton <ITranslationUpdater, TranslationUpdater>();
            container.RegisterSingleton <IPipeMessageHandler, NewPipeJobHandler>();

            container.RegisterSingleton <IVersionHelper>(() => new VersionHelper(GetType().Assembly));
            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 <IDefaultViewerCheck, DefaultViewerCheck>();

            container.RegisterCollection <ISettingsNavigationCheck>(new[]
            {
                typeof(NavigateProfileCheck),
                typeof(NavigateDefaultViewerCheck)
            });

            container.Register <ITabSwitchSettingsCheck, TabSwitchSettingsCheck>();
            container.Register <EvaluateSavingRelevantSettingsAndNotifyUserCommand>();
            container.Register <EvaluateTabSwitchRelevantSettingsAndNotifyUserCommand>();

            container.Register <IAppSettingsChecker, AppSettingsChecker>();
            container.Register <IPrinterActionsAssistant, PrinterActionsAssistant>();
            container.Register <IRepairPrinterAssistant, RepairPrinterAssistant>();
            container.Register <IDispatcher, DispatcherWrapper>();
            container.RegisterSingleton <ISettingsMover, SettingsMover>();
            container.RegisterSingleton <IRegistryUtility, RegistryUtility>();
            container.RegisterSingleton <ITokenHelper, TokenHelper>();
            container.Register <IMaybePipedApplicationStarter, MaybePipedApplicationStarter>();
            container.Register <ITokenReplacerFactory, TokenReplacerFactory>();

            container.RegisterSingleton <ISettingsChanged, SettingsChanged>();

            container.RegisterSingleton <IJobHistoryStorage, JobHistoryJsonFileStorage>();
            container.RegisterSingleton <IJobHistoryManager, JobHistoryManager>();

            container.RegisterSingleton <IDefaultSettingsBuilder, CreatorDefaultSettingsBuilder>();

            container.RegisterSingleton <IMigrationStorageFactory>(() =>
                                                                   new MigrationStorageFactory((baseStorage, targetVersion) => new CreatorSettingsMigrationStorage(baseStorage, targetVersion)));

            container.Register <IIniSettingsAssistant, CreatorIniSettingsAssistant>();
            container.RegisterSingleton <IIniSettingsLoader, IniSettingsLoader>();
            container.RegisterSingleton <IDataStorageFactory, DataStorageFactory>();
            container.RegisterSingleton <IJobInfoManager, JobInfoManager>();
            container.Register <IStaticPropertiesHack, StaticPropertiesHack>();

            container.Register <IManagePrintJobExceptionHandler, ManagePrintJobExceptionHandler>();
            container.Register <IFolderCleaner, FolderCleaner>();
            container.Register <IPdfCreatorFolderCleanUp, PdfCreatorFolderCleanUp>();

            container.Register <ISpooledJobFinder, SpooledJobFinder>();

            container.Register <IFtpConnectionFactory, FtpConnectionFactory>();
            container.Register <IScriptActionHelper, ScriptAction>();

            container.Register <IWorkflowNavigationHelper, WorkflowNavigationHelper>();

            container.Register <IDropboxService, DropboxService>();
            container.Register <IClipboardService, ClipboardService>();
            container.Register <IWinInetHelper, WinInetHelper>();
            container.RegisterSingleton <ITitleReplacerProvider, SettingsTitleReplacerProvider>();
            container.RegisterSingleton <IUpdateChangeParser, UpdateChangeParser>();

            container.RegisterSingleton <IMainWindowThreadLauncher, MainShellLauncher>();
            container.Register <ILastSaveDirectoryHelper, LastSaveDirectoryHelper>();
            container.Register <ITokenViewModelFactory, TokenViewModelFactory>();

            container.RegisterSingleton <IRegionHelper, RegionHelper>();
            container.Register <ISaveChangedSettingsCommand, SaveChangedSettingsCommand>();
            container.RegisterInitializer <FtpAccountViewModel>(model => model.AllowConversionInterrupts        = true);
            container.RegisterInitializer <HttpAccountViewModel>(model => model.AllowConversionInterrupts       = true);
            container.RegisterInitializer <SmtpAccountViewModel>(model => model.AllowConversionInterrupts       = true);
            container.RegisterInitializer <PrintUserControlViewModel>(model => model.PrinterDialogOptionEnabled = true);
            container.RegisterSingleton <IGpoSettings>(GetGpoSettings);
            container.Register <UsageStatisticsViewModelBase, PdfCreatorUsageStatisticsViewModel>();
            container.RegisterSingleton <ISigningPositionToUnitConverterFactory, SigningPositionToUnitConverterFactory>();

            RegisterSettingsLoader(container);
            RegisterCurrentSettingsProvider(container);
            RegisterFolderProvider(container);
            RegisterUserGuideHelper(container);
            RegisterTranslator(container);
            RegisterMailSigantureHelper(container);
            RegisterParameterSettingsManager(container);
            RegisterSettingsHelper(container);
            RegisterStartupConditions(container);
            RegisterActions(container);
            RegisterActionChecks(container);
            RegisterFileNameQuery(container);
            RegisterUpdateAssistant(container);
            RegisterJobBuilder(container);
            RegisterInteractiveWorkflowManagerFactory(container);
            RegisterPdfProcessor(container);
            RegisterUserTokenExtractor(container);
            RegisterPlusHintHelper(container);
            RegisterFirstTimeCommand(container);
            RegisterNotificationService(container);
            RegisterAllTypedSettingsProvider(container);
            RegisterBannerManager(container);
            container.RegisterSingleton(BuildCustomization);
            container.RegisterSingleton <IHttpHandler, HttpClientWrapper>();
            container.RegisterSingleton <IRssHttpClientFactory, RssHttpClientFactory>();
            container.RegisterSingleton <IKernel32, Kernel32>();
            container.RegisterSingleton <IMachineIdGenerator, MachineIdGenerator>();
            container.RegisterSingleton <IPdfCreatorUsageStatisticsManager, PdfCreatorUsageStatisticsManager>();
            container.RegisterSingleton <IUsageStatisticsSender, UsageStatisticsSender>();
            container.RegisterSingleton <IJobEventsManager, JobEventsManager>();
            container.RegisterSingleton <IRssService, RssService>();

            container.RegisterInitializer <StartupNavigationAction>(action =>
            {
                action.Region = RegionNames.MainRegion;
                action.Target = MainRegionViewNames.HomeView;
            });

            container.RegisterCollection <IStartupAction>(RegisterAndGetStartupActions(container));

            container.RegisterCollection <IJobEventsHandler>(new[]
            {
                typeof(UsageStatisticsEventsHandler)
            });
        }