Beispiel #1
0
        static Form WireupDependenciesAndCreateMainForm()
        {
            var tracer = new LJTraceSource("App", "app");

            using (tracer.NewFrame)
            {
                ILogProviderFactoryRegistry  logProviderFactoryRegistry  = new LogProviderFactoryRegistry();
                IFormatDefinitionsRepository formatDefinitionsRepository = new DirectoryFormatsRepository(null);
                ITempFilesManager            tempFilesManager            = LogJoint.TempFilesManager.GetInstance();
                IUserDefinedFormatsManager   userDefinedFormatsManager   = new UserDefinedFormatsManager(
                    formatDefinitionsRepository, logProviderFactoryRegistry, tempFilesManager);
                var appInitializer = new AppInitializer(tracer, userDefinedFormatsManager, logProviderFactoryRegistry);
                tracer.Info("app initializer created");
                var mainForm = new UI.MainForm();
                tracer.Info("main form created");
                IInvokeSynchronization     invokingSynchronization = new InvokeSynchronization(mainForm);
                UI.HeartBeatTimer          heartBeatTimer          = new UI.HeartBeatTimer(mainForm);
                UI.Presenters.IViewUpdates viewUpdates             = heartBeatTimer;
                IFiltersFactory            filtersFactory          = new FiltersFactory();
                IBookmarksFactory          bookmarksFactory        = new BookmarksFactory();
                var bookmarks = bookmarksFactory.CreateBookmarks();
                var persistentUserDataFileSystem = Persistence.Implementation.DesktopFileSystemAccess.CreatePersistentUserDataFileSystem();
                Persistence.Implementation.IStorageManagerImplementation userDataStorage = new Persistence.Implementation.StorageManagerImplementation();
                IShutdown shutdown = new Shutdown();
                Persistence.IStorageManager      storageManager         = new Persistence.PersistentUserDataManager(userDataStorage, shutdown);
                Settings.IGlobalSettingsAccessor globalSettingsAccessor = new Settings.GlobalSettingsAccessor(storageManager);
                userDataStorage.Init(
                    new Persistence.Implementation.RealTimingAndThreading(),
                    persistentUserDataFileSystem,
                    new Persistence.PersistentUserDataManager.ConfigAccess(globalSettingsAccessor)
                    );
                Persistence.IFirstStartDetector firstStartDetector = persistentUserDataFileSystem;
                Persistence.Implementation.IStorageManagerImplementation contentCacheStorage = new Persistence.Implementation.StorageManagerImplementation();
                contentCacheStorage.Init(
                    new Persistence.Implementation.RealTimingAndThreading(),
                    Persistence.Implementation.DesktopFileSystemAccess.CreateCacheFileSystemAccess(),
                    new Persistence.ContentCacheManager.ConfigAccess(globalSettingsAccessor)
                    );
                Properties.WebContentConfig  webContentConfig = new Properties.WebContentConfig();
                Persistence.IContentCache    contentCache     = new Persistence.ContentCacheManager(contentCacheStorage);
                Persistence.IWebContentCache webContentCache  = new Persistence.WebContentCache(
                    contentCache,
                    webContentConfig
                    );
                MultiInstance.IInstancesCounter     instancesCounter          = new MultiInstance.InstancesCounter(shutdown);
                Progress.IProgressAggregatorFactory progressAggregatorFactory = new Progress.ProgressAggregator.Factory(heartBeatTimer, invokingSynchronization);
                Progress.IProgressAggregator        progressAggregator        = progressAggregatorFactory.CreateProgressAggregator();

                IAdjustingColorsGenerator colorGenerator = new AdjustingColorsGenerator(
                    new PastelColorsGenerator(),
                    globalSettingsAccessor.Appearance.ColoringBrightness
                    );

                IModelThreads modelThreads = new ModelThreads(colorGenerator);

                ILogSourcesManager logSourcesManager = new LogSourcesManager(
                    heartBeatTimer,
                    invokingSynchronization,
                    modelThreads,
                    tempFilesManager,
                    storageManager,
                    bookmarks,
                    globalSettingsAccessor
                    );

                Telemetry.ITelemetryUploader telemetryUploader =
                    new Telemetry.ConfiguredAzureTelemetryUploader();

                Telemetry.ITelemetryCollector telemetryCollector = new Telemetry.TelemetryCollector(
                    storageManager,
                    telemetryUploader,
                    invokingSynchronization,
                    instancesCounter,
                    shutdown,
                    logSourcesManager,
                    new MemBufferTraceAccess()
                    );
                tracer.Info("telemetry created");

                MRU.IRecentlyUsedEntities recentlyUsedLogs = new MRU.RecentlyUsedEntities(
                    storageManager,
                    logProviderFactoryRegistry,
                    telemetryCollector
                    );

                IFormatAutodetect formatAutodetect = new FormatAutodetect(
                    recentlyUsedLogs,
                    logProviderFactoryRegistry,
                    tempFilesManager
                    );

                Workspaces.IWorkspacesManager workspacesManager = new Workspaces.WorkspacesManager(
                    logSourcesManager,
                    logProviderFactoryRegistry,
                    storageManager,
                    new Workspaces.Backend.AzureWorkspacesBackend(),
                    tempFilesManager,
                    recentlyUsedLogs,
                    shutdown
                    );

                AppLaunch.ILaunchUrlParser launchUrlParser = new AppLaunch.LaunchUrlParser();

                var pluggableProtocolManager = new PluggableProtocolManager(
                    instancesCounter,
                    shutdown,
                    telemetryCollector,
                    firstStartDetector,
                    launchUrlParser
                    );

                Preprocessing.IPreprocessingManagerExtensionsRegistry preprocessingManagerExtensionsRegistry =
                    new Preprocessing.PreprocessingManagerExtentionsRegistry();

                Preprocessing.ICredentialsCache preprocessingCredentialsCache = new UI.LogsPreprocessorCredentialsCache(
                    invokingSynchronization,
                    storageManager.GlobalSettingsEntry,
                    mainForm
                    );

                WebBrowserDownloader.IDownloader webBrowserDownloader = new UI.Presenters.WebBrowserDownloader.Presenter(
                    new LogJoint.UI.WebBrowserDownloader.WebBrowserDownloaderForm(),
                    invokingSynchronization,
                    webContentCache,
                    shutdown
                    );

                Preprocessing.IPreprocessingStepsFactory preprocessingStepsFactory = new Preprocessing.PreprocessingStepsFactory(
                    workspacesManager,
                    launchUrlParser,
                    invokingSynchronization,
                    preprocessingManagerExtensionsRegistry,
                    progressAggregator,
                    webContentCache,
                    preprocessingCredentialsCache,
                    logProviderFactoryRegistry,
                    webBrowserDownloader,
                    webContentConfig
                    );

                Preprocessing.ILogSourcesPreprocessingManager logSourcesPreprocessings = new Preprocessing.LogSourcesPreprocessingManager(
                    invokingSynchronization,
                    formatAutodetect,
                    preprocessingManagerExtensionsRegistry,
                    new Preprocessing.BuiltinStepsExtension(preprocessingStepsFactory),
                    telemetryCollector,
                    tempFilesManager
                    );

                ISearchManager searchManager = new SearchManager(
                    logSourcesManager,
                    progressAggregatorFactory,
                    invokingSynchronization,
                    globalSettingsAccessor,
                    telemetryCollector,
                    heartBeatTimer
                    );

                IUserDefinedSearches userDefinedSearches = new UserDefinedSearchesManager(storageManager, filtersFactory, invokingSynchronization);

                ISearchHistory searchHistory = new SearchHistory(storageManager.GlobalSettingsEntry, userDefinedSearches);

                ILogSourcesController logSourcesController = new LogSourcesController(
                    logSourcesManager,
                    logSourcesPreprocessings,
                    recentlyUsedLogs,
                    shutdown
                    );

                IBookmarksController bookmarksController = new BookmarkController(
                    bookmarks,
                    modelThreads,
                    heartBeatTimer
                    );

                IFiltersManager filtersManager = new FiltersManager(
                    filtersFactory,
                    globalSettingsAccessor,
                    logSourcesManager,
                    colorGenerator,
                    shutdown
                    );

                Postprocessing.IUserNamesProvider analyticsShortNames = new Postprocessing.CodenameUserNamesProvider(
                    logSourcesManager
                    );

                Analytics.TimeSeries.ITimeSeriesTypesAccess timeSeriesTypesAccess = new Analytics.TimeSeries.TimeSeriesTypesLoader();

                Postprocessing.IPostprocessorsManager postprocessorsManager = new Postprocessing.PostprocessorsManager(
                    logSourcesManager,
                    telemetryCollector,
                    invokingSynchronization,
                    heartBeatTimer,
                    progressAggregator,
                    null                     // todo
                    );

                Postprocessing.InternalTracePostprocessors.Register(
                    postprocessorsManager,
                    userDefinedFormatsManager
                    );

                tracer.Info("model creation completed");


                var presentersFacade = new UI.Presenters.Facade();
                UI.Presenters.IPresentersFacade navHandler = presentersFacade;

                UI.Presenters.IClipboardAccess clipboardAccess = new ClipboardAccess(telemetryCollector);

                UI.Presenters.IShellOpen shellOpen = new ShellOpen();

                UI.Presenters.LogViewer.IPresenterFactory logViewerPresenterFactory = new UI.Presenters.LogViewer.PresenterFactory(
                    heartBeatTimer,
                    presentersFacade,
                    clipboardAccess,
                    bookmarksFactory,
                    telemetryCollector,
                    logSourcesManager,
                    invokingSynchronization,
                    modelThreads,
                    filtersManager.HighlightFilters,
                    bookmarks,
                    globalSettingsAccessor,
                    searchManager,
                    filtersFactory
                    );

                UI.Presenters.LoadedMessages.IView      loadedMessagesView      = mainForm.loadedMessagesControl;
                UI.Presenters.LoadedMessages.IPresenter loadedMessagesPresenter = new UI.Presenters.LoadedMessages.Presenter(
                    logSourcesManager,
                    bookmarks,
                    loadedMessagesView,
                    heartBeatTimer,
                    logViewerPresenterFactory
                    );

                UI.Presenters.LogViewer.IPresenter viewerPresenter = loadedMessagesPresenter.LogViewerPresenter;

                UI.Presenters.ITabUsageTracker tabUsageTracker = new UI.Presenters.TabUsageTracker();

                UI.Presenters.StatusReports.IPresenter statusReportsPresenter = new UI.Presenters.StatusReports.Presenter(
                    new UI.StatusReportView(
                        mainForm,
                        mainForm.toolStripStatusLabel,
                        mainForm.cancelLongRunningProcessDropDownButton,
                        mainForm.cancelLongRunningProcessLabel
                        ),
                    heartBeatTimer
                    );
                UI.Presenters.StatusReports.IPresenter statusReportFactory = statusReportsPresenter;

                UI.Presenters.Timeline.IPresenter timelinePresenter = new UI.Presenters.Timeline.Presenter(
                    logSourcesManager,
                    logSourcesPreprocessings,
                    searchManager,
                    bookmarks,
                    mainForm.timeLinePanel.TimelineControl,
                    viewerPresenter,
                    statusReportFactory,
                    tabUsageTracker,
                    heartBeatTimer);

                UI.Presenters.TimelinePanel.IPresenter timelinePanelPresenter = new UI.Presenters.TimelinePanel.Presenter(
                    logSourcesManager,
                    bookmarks,
                    mainForm.timeLinePanel,
                    timelinePresenter,
                    heartBeatTimer);

                UI.Presenters.SearchResult.IPresenter searchResultPresenter = new UI.Presenters.SearchResult.Presenter(
                    searchManager,
                    bookmarks,
                    filtersManager.HighlightFilters,
                    mainForm.searchResultView,
                    navHandler,
                    loadedMessagesPresenter,
                    heartBeatTimer,
                    invokingSynchronization,
                    statusReportFactory,
                    logViewerPresenterFactory
                    );

                UI.Presenters.ThreadsList.IPresenter threadsListPresenter = new UI.Presenters.ThreadsList.Presenter(
                    modelThreads,
                    logSourcesManager,
                    mainForm.threadsListView,
                    viewerPresenter,
                    navHandler,
                    viewUpdates,
                    heartBeatTimer);
                tracer.Info("threads list presenter created");

                var dialogs = new Alerts();
                UI.Presenters.IAlertPopup  alertPopup  = dialogs;
                UI.Presenters.IFileDialogs fileDialogs = dialogs;

                UI.Presenters.SearchEditorDialog.IPresenter searchEditorDialog = new UI.Presenters.SearchEditorDialog.Presenter(
                    new SearchEditorDialogView(),
                    userDefinedSearches,
                    (filtersList, dialogView) =>
                {
                    UI.Presenters.FilterDialog.IPresenter filterDialogPresenter = new UI.Presenters.FilterDialog.Presenter(
                        null,
                        filtersList,
                        new UI.FilterDialogView()
                        );
                    return(new UI.Presenters.FiltersManager.Presenter(
                               filtersList,
                               dialogView.FiltersManagerView,
                               new UI.Presenters.FiltersListBox.Presenter(
                                   filtersList,
                                   dialogView.FiltersManagerView.FiltersListView,
                                   filterDialogPresenter
                                   ),
                               filterDialogPresenter,
                               null,
                               viewUpdates,
                               heartBeatTimer,
                               filtersFactory,
                               alertPopup
                               ));
                },
                    alertPopup
                    );

                UI.Presenters.SearchesManagerDialog.IPresenter searchesManagerDialogPresenter = new UI.Presenters.SearchesManagerDialog.Presenter(
                    new UI.SearchesManagerDialogView(),
                    userDefinedSearches,
                    alertPopup,
                    fileDialogs,
                    searchEditorDialog
                    );

                UI.Presenters.SearchPanel.IPresenter searchPanelPresenter = new UI.Presenters.SearchPanel.Presenter(
                    mainForm.searchPanelView,
                    searchManager,
                    searchHistory,
                    userDefinedSearches,
                    logSourcesManager,
                    filtersFactory,
                    new UI.SearchResultsPanelView()
                {
                    container = mainForm.splitContainer_Log_SearchResults
                },
                    loadedMessagesPresenter,
                    searchResultPresenter,
                    statusReportFactory,
                    searchEditorDialog,
                    searchesManagerDialogPresenter,
                    alertPopup
                    );
                tracer.Info("search panel presenter created");


                UI.Presenters.SourcePropertiesWindow.IPresenter sourcePropertiesWindowPresenter =
                    new UI.Presenters.SourcePropertiesWindow.Presenter(
                        new UI.SourceDetailsWindowView(),
                        logSourcesManager,
                        logSourcesPreprocessings,
                        navHandler,
                        alertPopup,
                        clipboardAccess,
                        shellOpen
                        );

                UI.Presenters.SourcesList.IPresenter sourcesListPresenter = new UI.Presenters.SourcesList.Presenter(
                    logSourcesManager,
                    mainForm.sourcesListView.SourcesListView,
                    logSourcesPreprocessings,
                    sourcePropertiesWindowPresenter,
                    viewerPresenter,
                    navHandler,
                    alertPopup,
                    fileDialogs,
                    clipboardAccess,
                    shellOpen
                    );


                UI.LogsPreprocessorUI logsPreprocessorUI = new UI.LogsPreprocessorUI(
                    logSourcesPreprocessings,
                    mainForm,
                    statusReportsPresenter);

                UI.Presenters.Help.IPresenter helpPresenter = new UI.Presenters.Help.Presenter(shellOpen);

                AppLaunch.ICommandLineHandler commandLineHandler = new AppLaunch.CommandLineHandler(
                    logSourcesPreprocessings,
                    preprocessingStepsFactory);

                UI.Presenters.SharingDialog.IPresenter sharingDialogPresenter = new UI.Presenters.SharingDialog.Presenter(
                    logSourcesManager,
                    workspacesManager,
                    logSourcesPreprocessings,
                    alertPopup,
                    clipboardAccess,
                    new UI.ShareDialog()
                    );

                UI.Presenters.HistoryDialog.IView      historyDialogView      = new UI.HistoryDialog();
                UI.Presenters.HistoryDialog.IPresenter historyDialogPresenter = new UI.Presenters.HistoryDialog.Presenter(
                    logSourcesController,
                    historyDialogView,
                    logSourcesPreprocessings,
                    preprocessingStepsFactory,
                    recentlyUsedLogs,
                    new UI.Presenters.QuickSearchTextBox.Presenter(historyDialogView.QuickSearchTextBox),
                    alertPopup
                    );

                UI.Presenters.NewLogSourceDialog.IPagePresentersRegistry newLogPagesPresentersRegistry =
                    new UI.Presenters.NewLogSourceDialog.PagePresentersRegistry();

                UI.Presenters.NewLogSourceDialog.IPresenter newLogSourceDialogPresenter = new UI.Presenters.NewLogSourceDialog.Presenter(
                    logProviderFactoryRegistry,
                    newLogPagesPresentersRegistry,
                    recentlyUsedLogs,
                    new UI.NewLogSourceDialogView(),
                    userDefinedFormatsManager,
                    () => new UI.Presenters.NewLogSourceDialog.Pages.FormatDetection.Presenter(
                        new UI.Presenters.NewLogSourceDialog.Pages.FormatDetection.AnyLogFormatUI(),
                        logSourcesPreprocessings,
                        preprocessingStepsFactory
                        ),
                    new UI.Presenters.FormatsWizard.Presenter(
                        new UI.Presenters.FormatsWizard.ObjectsFactory(
                            alertPopup,
                            fileDialogs,
                            helpPresenter,
                            logProviderFactoryRegistry,
                            formatDefinitionsRepository,
                            userDefinedFormatsManager,
                            tempFilesManager,
                            logViewerPresenterFactory,
                            new UI.Presenters.FormatsWizard.ObjectsFactory.ViewFactories()
                {
                    CreateFormatsWizardView           = () => new ManageFormatsWizard(),
                    CreateChooseOperationPageView     = () => new ChooseOperationPage(),
                    CreateImportLog4NetPagePageView   = () => new ImportLog4NetPage(),
                    CreateFormatIdentityPageView      = () => new FormatIdentityPage(),
                    CreateFormatAdditionalOptionsPage = () => new FormatAdditionalOptionsPage(),
                    CreateSaveFormatPageView          = () => new SaveFormatPage(),
                    CreateImportNLogPage               = () => new ImportNLogPage(),
                    CreateNLogGenerationLogPageView    = () => new NLogGenerationLogPage(),
                    CreateChooseExistingFormatPageView = () => new ChooseExistingFormatPage(),
                    CreateFormatDeleteConfirmPageView  = () => new FormatDeleteConfirmPage(),
                    CreateRegexBasedFormatPageView     = () => new RegexBasedFormatPage(),
                    CreateEditSampleDialogView         = () => new EditSampleLogForm(),
                    CreateTestDialogView               = () => new TestParserForm(),
                    CreateEditRegexDialog              = () => new EditRegexForm(),
                    CreateEditFieldsMappingDialog      = () => new FieldsMappingForm(),
                    CreateXmlBasedFormatPageView       = () => new XmlBasedFormatPage(),
                    CreateXsltEditorDialog             = () => new EditXsltForm(),
                }
                            )
                        )
                    );

                newLogPagesPresentersRegistry.RegisterPagePresenterFactory(
                    StdProviderFactoryUIs.FileBasedProviderUIKey,
                    f => new UI.Presenters.NewLogSourceDialog.Pages.FileBasedFormat.Presenter(
                        new UI.Presenters.NewLogSourceDialog.Pages.FileBasedFormat.FileLogFactoryUI(),
                        (IFileBasedLogProviderFactory)f,
                        logSourcesController,
                        alertPopup,
                        fileDialogs
                        )
                    );
                newLogPagesPresentersRegistry.RegisterPagePresenterFactory(
                    StdProviderFactoryUIs.DebugOutputProviderUIKey,
                    f => new UI.Presenters.NewLogSourceDialog.Pages.DebugOutput.Presenter(
                        new UI.Presenters.NewLogSourceDialog.Pages.DebugOutput.DebugOutputFactoryUI(),
                        f,
                        logSourcesController
                        )
                    );
                newLogPagesPresentersRegistry.RegisterPagePresenterFactory(
                    StdProviderFactoryUIs.WindowsEventLogProviderUIKey,
                    f => new UI.Presenters.NewLogSourceDialog.Pages.WindowsEventsLog.Presenter(
                        new UI.Presenters.NewLogSourceDialog.Pages.WindowsEventsLog.EVTFactoryUI(),
                        f,
                        logSourcesController
                        )
                    );

                UI.Presenters.SourcesManager.IPresenter sourcesManagerPresenter = new UI.Presenters.SourcesManager.Presenter(
                    logSourcesManager,
                    userDefinedFormatsManager,
                    recentlyUsedLogs,
                    logSourcesPreprocessings,
                    logSourcesController,
                    mainForm.sourcesListView,
                    preprocessingStepsFactory,
                    workspacesManager,
                    sourcesListPresenter,
                    newLogSourceDialogPresenter,
                    heartBeatTimer,
                    sharingDialogPresenter,
                    historyDialogPresenter,
                    presentersFacade,
                    sourcePropertiesWindowPresenter,
                    alertPopup
                    );


                UI.Presenters.MessagePropertiesDialog.IPresenter messagePropertiesDialogPresenter = new UI.Presenters.MessagePropertiesDialog.Presenter(
                    bookmarks,
                    filtersManager.HighlightFilters,
                    new MessagePropertiesDialogView(mainForm),
                    viewerPresenter,
                    navHandler);


                Func <IFiltersList, UI.Presenters.FiltersManager.IView, UI.Presenters.FiltersManager.IPresenter> createFiltersManager = (filters, view) =>
                {
                    var dialogPresenter = new UI.Presenters.FilterDialog.Presenter(logSourcesManager, filters, new UI.FilterDialogView());
                    UI.Presenters.FiltersListBox.IPresenter listPresenter    = new UI.Presenters.FiltersListBox.Presenter(filters, view.FiltersListView, dialogPresenter);
                    UI.Presenters.FiltersManager.IPresenter managerPresenter = new UI.Presenters.FiltersManager.Presenter(
                        filters,
                        view,
                        listPresenter,
                        dialogPresenter,
                        viewerPresenter,
                        viewUpdates,
                        heartBeatTimer,
                        filtersFactory,
                        alertPopup
                        );
                    return(managerPresenter);
                };

                UI.Presenters.FiltersManager.IPresenter hlFiltersManagerPresenter = createFiltersManager(
                    filtersManager.HighlightFilters,
                    mainForm.hlFiltersManagementView);

                UI.Presenters.BookmarksList.IPresenter bookmarksListPresenter = new UI.Presenters.BookmarksList.Presenter(
                    bookmarks,
                    logSourcesManager,
                    mainForm.bookmarksManagerView.ListView,
                    heartBeatTimer,
                    loadedMessagesPresenter,
                    clipboardAccess);

                UI.Presenters.BookmarksManager.IPresenter bookmarksManagerPresenter = new UI.Presenters.BookmarksManager.Presenter(
                    bookmarks,
                    mainForm.bookmarksManagerView,
                    viewerPresenter,
                    searchResultPresenter,
                    bookmarksListPresenter,
                    statusReportFactory,
                    navHandler,
                    viewUpdates,
                    alertPopup
                    );

                AutoUpdate.IAutoUpdater autoUpdater = new AutoUpdate.AutoUpdater(
                    instancesCounter,
                    new AutoUpdate.ConfiguredAzureUpdateDownloader(),
                    tempFilesManager,
                    shutdown,
                    invokingSynchronization,
                    firstStartDetector,
                    telemetryCollector,
                    storageManager
                    );


                var unhandledExceptionsReporter = new Telemetry.WinFormsUnhandledExceptionsReporter(
                    telemetryCollector
                    );

                UI.Presenters.Options.Dialog.IPresenter optionsDialogPresenter = new UI.Presenters.Options.Dialog.Presenter(
                    new OptionsDialogView(),
                    pageView => new UI.Presenters.Options.MemAndPerformancePage.Presenter(globalSettingsAccessor, recentlyUsedLogs, searchHistory, pageView),
                    pageView => new UI.Presenters.Options.Appearance.Presenter(globalSettingsAccessor, pageView, logViewerPresenterFactory),
                    pageView => new UI.Presenters.Options.UpdatesAndFeedback.Presenter(autoUpdater, globalSettingsAccessor, pageView)
                    );

                DragDropHandler dragDropHandler = new DragDropHandler(
                    logSourcesController,
                    logSourcesPreprocessings,
                    preprocessingStepsFactory
                    );

                UI.Presenters.About.IPresenter aboutDialogPresenter = new UI.Presenters.About.Presenter(
                    new AboutBox(),
                    new AboutDialogConfig(),
                    clipboardAccess,
                    autoUpdater
                    );

                UI.Presenters.TimestampAnomalyNotification.IPresenter timestampAnomalyNotificationPresenter = new UI.Presenters.TimestampAnomalyNotification.Presenter(
                    logSourcesManager,
                    logSourcesPreprocessings,
                    invokingSynchronization,
                    heartBeatTimer,
                    presentersFacade,
                    statusReportsPresenter
                    );

                UI.Presenters.IPromptDialog promptDialog = new UI.PromptDialog.Presenter();

                UI.Presenters.IssueReportDialogPresenter.IPresenter issueReportDialogPresenter =
                    new UI.Presenters.IssueReportDialogPresenter.Presenter(telemetryCollector, telemetryUploader, promptDialog);

                UI.Presenters.MainForm.IPresenter mainFormPresenter = new UI.Presenters.MainForm.Presenter(
                    logSourcesManager,
                    logSourcesPreprocessings,
                    mainForm,
                    viewerPresenter,
                    searchResultPresenter,
                    searchPanelPresenter,
                    sourcesListPresenter,
                    sourcesManagerPresenter,
                    messagePropertiesDialogPresenter,
                    loadedMessagesPresenter,
                    bookmarksManagerPresenter,
                    heartBeatTimer,
                    tabUsageTracker,
                    statusReportFactory,
                    dragDropHandler,
                    navHandler,
                    autoUpdater,
                    progressAggregator,
                    alertPopup,
                    sharingDialogPresenter,
                    issueReportDialogPresenter,
                    shutdown
                    );
                tracer.Info("main form presenter created");


                var postprocessingViewsFactory = new UI.Postprocessing.PostprocessorOutputFormFactory();

                UI.Presenters.Postprocessing.MainWindowTabPage.IView postprocessingTabPage = new UI.Postprocessing.MainWindowTabPage.TabPage(
                    mainFormPresenter
                    );
                UI.Presenters.Postprocessing.MainWindowTabPage.IPresenter postprocessingTabPagePresenter = new UI.Presenters.Postprocessing.MainWindowTabPage.PluginTabPagePresenter(
                    postprocessingTabPage,
                    postprocessorsManager,
                    postprocessingViewsFactory,
                    logSourcesManager,
                    tempFilesManager,
                    shellOpen,
                    newLogSourceDialogPresenter,
                    telemetryCollector
                    );

                Postprocessing.IAggregatingLogSourceNamesProvider logSourceNamesProvider = new Postprocessing.AggregatingLogSourceNamesProvider();

                Extensibility.IApplication pluginEntryPoint = new Extensibility.Application(
                    new Extensibility.Model(
                        invokingSynchronization,
                        telemetryCollector,
                        webContentCache,
                        contentCache,
                        storageManager,
                        bookmarks,
                        logSourcesManager,
                        modelThreads,
                        tempFilesManager,
                        preprocessingManagerExtensionsRegistry,
                        logSourcesPreprocessings,
                        preprocessingStepsFactory,
                        progressAggregator,
                        logProviderFactoryRegistry,
                        userDefinedFormatsManager,
                        recentlyUsedLogs,
                        progressAggregatorFactory,
                        heartBeatTimer,
                        logSourcesController,
                        shutdown,
                        webBrowserDownloader,
                        commandLineHandler,
                        postprocessorsManager,
                        analyticsShortNames,
                        timeSeriesTypesAccess,
                        logSourceNamesProvider
                        ),
                    new Extensibility.Presentation(
                        loadedMessagesPresenter,
                        clipboardAccess,
                        presentersFacade,
                        sourcesManagerPresenter,
                        newLogSourceDialogPresenter,
                        shellOpen,
                        alertPopup,
                        promptDialog,
                        mainFormPresenter,
                        postprocessingTabPagePresenter,
                        postprocessingViewsFactory
                        ),
                    new Extensibility.View(
                        mainForm
                        )
                    );

                var pluginsManager = new Extensibility.PluginsManager(
                    pluginEntryPoint,
                    mainFormPresenter,
                    telemetryCollector,
                    shutdown
                    );
                tracer.Info("plugin manager created");

                appInitializer.WireUpCommandLineHandler(mainFormPresenter, commandLineHandler);
                postprocessingViewsFactory.Init(pluginEntryPoint);

                presentersFacade.Init(
                    messagePropertiesDialogPresenter,
                    threadsListPresenter,
                    sourcesListPresenter,
                    bookmarksManagerPresenter,
                    mainFormPresenter,
                    aboutDialogPresenter,
                    optionsDialogPresenter,
                    historyDialogPresenter
                    );

                return(mainForm);
            }
        }
Beispiel #2
0
        public static ModelObjects Create(
            ModelConfig config,
            ISynchronizationContext modelSynchronizationContext,
            Func <Persistence.IStorageManager, Preprocessing.ICredentialsCache> createPreprocessingCredentialsCache,
            Func <IShutdownSource, Persistence.IWebContentCache, ITraceSourceFactory, WebViewTools.IWebViewTools> createWebBrowserDownloader
            )
        {
            ITraceSourceFactory traceSourceFactory = new TraceSourceFactory(config.TraceListeners);
            IShutdownSource     shutdown           = new Shutdown();
            var tracer = traceSourceFactory.CreateTraceSource("App", "model");

            Telemetry.UnhandledExceptionsReporter.SetupLogging(tracer, shutdown);
            ILogProviderFactoryRegistry  logProviderFactoryRegistry  = new LogProviderFactoryRegistry();
            IFormatDefinitionsRepository formatDefinitionsRepository = new DirectoryFormatsRepository(null);

            MultiInstance.IInstancesCounter instancesCounter    = new MultiInstance.InstancesCounter(shutdown);
            ITempFilesManager         tempFilesManager          = new TempFilesManager(traceSourceFactory, instancesCounter);
            UserDefinedFormatsManager userDefinedFormatsManager = new UserDefinedFormatsManager(
                formatDefinitionsRepository, logProviderFactoryRegistry, tempFilesManager, traceSourceFactory);

            RegisterUserDefinedFormats(userDefinedFormatsManager);
            RegisterPredefinedFormatFactories(logProviderFactoryRegistry, tempFilesManager, userDefinedFormatsManager);
            tracer.Info("app initializer created");
            ISynchronizationContext threadPoolSynchronizationContext = new ThreadPoolSynchronizationContext();
            IChangeNotification     changeNotification = new ChangeNotification(modelSynchronizationContext);
            IFiltersFactory         filtersFactory     = new FiltersFactory(changeNotification);
            IBookmarksFactory       bookmarksFactory   = new BookmarksFactory(changeNotification);
            var bookmarks = bookmarksFactory.CreateBookmarks();
            var persistentUserDataFileSystem = Persistence.Implementation.DesktopFileSystemAccess.CreatePersistentUserDataFileSystem(config.AppDataDirectory);

            Persistence.Implementation.IStorageManagerImplementation userDataStorage = new Persistence.Implementation.StorageManagerImplementation();
            Persistence.IStorageManager      storageManager         = new Persistence.PersistentUserDataManager(traceSourceFactory, userDataStorage, shutdown);
            Settings.IGlobalSettingsAccessor globalSettingsAccessor = new Settings.GlobalSettingsAccessor(storageManager);
            userDataStorage.Init(
                new Persistence.Implementation.RealTimingAndThreading(),
                persistentUserDataFileSystem,
                new Persistence.PersistentUserDataManager.ConfigAccess(globalSettingsAccessor)
                );
            Persistence.IFirstStartDetector firstStartDetector = persistentUserDataFileSystem;
            Persistence.Implementation.IStorageManagerImplementation contentCacheStorage = new Persistence.Implementation.StorageManagerImplementation();
            contentCacheStorage.Init(
                new Persistence.Implementation.RealTimingAndThreading(),
                Persistence.Implementation.DesktopFileSystemAccess.CreateCacheFileSystemAccess(config.AppDataDirectory),
                new Persistence.ContentCacheManager.ConfigAccess(globalSettingsAccessor)
                );
            Persistence.IContentCache           contentCache          = new Persistence.ContentCacheManager(traceSourceFactory, contentCacheStorage);
            Persistence.IWebContentCacheConfig  webContentCacheConfig = config.WebContentCacheConfig;
            Preprocessing.ILogsDownloaderConfig logsDownloaderConfig  = config.LogsDownloaderConfig;
            Persistence.IWebContentCache        webContentCache       = new Persistence.WebContentCache(
                contentCache,
                webContentCacheConfig
                );
            IHeartBeatTimer heartBeatTimer = new HeartBeatTimer();

            Progress.IProgressAggregatorFactory progressAggregatorFactory = new Progress.ProgressAggregator.Factory(heartBeatTimer, modelSynchronizationContext);
            Progress.IProgressAggregator        progressAggregator        = progressAggregatorFactory.CreateProgressAggregator();

            var threadColorsLease = new ColorLease(1);
            IModelThreadsInternal modelThreads = new ModelThreads(threadColorsLease);

            Telemetry.ITelemetryUploader telemetryUploader = new Telemetry.AzureTelemetryUploader(
                traceSourceFactory,
                config.TelemetryUrl,
                config.IssuesUrl
                );

            var telemetryCollectorImpl = new Telemetry.TelemetryCollector(
                storageManager,
                telemetryUploader,
                modelSynchronizationContext,
                instancesCounter,
                shutdown,
                new MemBufferTraceAccess(),
                traceSourceFactory
                );

            Telemetry.ITelemetryCollector telemetryCollector = telemetryCollectorImpl;

            MRU.IRecentlyUsedEntities recentlyUsedLogs = new MRU.RecentlyUsedEntities(
                storageManager,
                logProviderFactoryRegistry,
                telemetryCollector
                );

            ILogSourcesManager logSourcesManager = new LogSourcesManager(
                heartBeatTimer,
                modelSynchronizationContext,
                modelThreads,
                tempFilesManager,
                storageManager,
                bookmarks,
                globalSettingsAccessor,
                recentlyUsedLogs,
                shutdown,
                traceSourceFactory,
                changeNotification
                );

            telemetryCollectorImpl.SetLogSourcesManager(logSourcesManager);

            Telemetry.UnhandledExceptionsReporter.Setup(telemetryCollector, shutdown);

            IFormatAutodetect formatAutodetect = new FormatAutodetect(
                recentlyUsedLogs,
                logProviderFactoryRegistry,
                tempFilesManager,
                traceSourceFactory
                );

            Workspaces.Backend.IBackendAccess workspacesBackendAccess = new Workspaces.Backend.AzureWorkspacesBackend(
                traceSourceFactory,
                config.WorkspacesUrl
                );

            Workspaces.IWorkspacesManager workspacesManager = new Workspaces.WorkspacesManager(
                logSourcesManager,
                logProviderFactoryRegistry,
                storageManager,
                workspacesBackendAccess,
                tempFilesManager,
                recentlyUsedLogs,
                shutdown,
                traceSourceFactory
                );

            AppLaunch.ILaunchUrlParser launchUrlParser = new AppLaunch.LaunchUrlParser();

            Preprocessing.IExtensionsRegistry preprocessingManagerExtensionsRegistry =
                new Preprocessing.PreprocessingManagerExtentionsRegistry(logsDownloaderConfig);

            Preprocessing.ICredentialsCache preprocessingCredentialsCache = createPreprocessingCredentialsCache(
                storageManager
                );

            WebViewTools.IWebViewTools webBrowserDownloader = createWebBrowserDownloader(shutdown, webContentCache, traceSourceFactory);

            Preprocessing.IStepsFactory preprocessingStepsFactory = new Preprocessing.PreprocessingStepsFactory(
                workspacesManager,
                launchUrlParser,
                modelSynchronizationContext,
                preprocessingManagerExtensionsRegistry,
                progressAggregator,
                webContentCache,
                preprocessingCredentialsCache,
                logProviderFactoryRegistry,
                webBrowserDownloader,
                logsDownloaderConfig,
                traceSourceFactory
                );

            Preprocessing.IManager logSourcesPreprocessings = new Preprocessing.LogSourcesPreprocessingManager(
                modelSynchronizationContext,
                formatAutodetect,
                preprocessingManagerExtensionsRegistry,
                new Preprocessing.BuiltinStepsExtension(preprocessingStepsFactory),
                telemetryCollector,
                tempFilesManager,
                logSourcesManager,
                shutdown,
                traceSourceFactory,
                changeNotification
                );

            ISearchManager searchManager = new SearchManager(
                logSourcesManager,
                progressAggregatorFactory,
                modelSynchronizationContext,
                globalSettingsAccessor,
                telemetryCollector,
                heartBeatTimer,
                changeNotification,
                traceSourceFactory
                );

            IUserDefinedSearches userDefinedSearches = new UserDefinedSearchesManager(storageManager, filtersFactory, modelSynchronizationContext);

            ISearchHistory searchHistory = new SearchHistory(storageManager.GlobalSettingsEntry, userDefinedSearches);

            IBookmarksController bookmarksController = new BookmarkController(
                bookmarks,
                modelThreads,
                heartBeatTimer
                );

            IFiltersManager filtersManager = new FiltersManager(
                filtersFactory,
                globalSettingsAccessor,
                logSourcesManager,
                shutdown
                );

            Postprocessing.IUserNamesProvider analyticsShortNames = new Postprocessing.CodenameUserNamesProvider(
                logSourcesManager
                );

            Postprocessing.TimeSeries.ITimeSeriesTypesAccess timeSeriesTypesAccess = new Postprocessing.TimeSeries.TimeSeriesTypesLoader();

            Postprocessing.IManager postprocessorsManager = new Postprocessing.PostprocessorsManager(
                logSourcesManager,
                telemetryCollector,
                modelSynchronizationContext,
                threadPoolSynchronizationContext,
                heartBeatTimer,
                progressAggregator,
                globalSettingsAccessor,
                new Postprocessing.OutputDataDeserializer(timeSeriesTypesAccess),
                traceSourceFactory
                );

            Postprocessing.IModel postprocessingModel = new Postprocessing.Model(
                postprocessorsManager,
                timeSeriesTypesAccess,
                new Postprocessing.StateInspector.Model(tempFilesManager),
                new Postprocessing.Timeline.Model(tempFilesManager),
                new Postprocessing.SequenceDiagram.Model(tempFilesManager),
                new Postprocessing.TimeSeries.Model(timeSeriesTypesAccess)
                );

            AutoUpdate.IFactory autoUpdateFactory = new AutoUpdate.Factory(
                tempFilesManager,
                traceSourceFactory,
                instancesCounter,
                shutdown,
                modelSynchronizationContext,
                firstStartDetector,
                telemetryCollector,
                storageManager,
                changeNotification,
                config.AutoUpdateUrl,
                config.PluginsUrl
                );

            AppLaunch.ICommandLineHandler commandLineHandler = new AppLaunch.CommandLineHandler(
                logSourcesPreprocessings,
                preprocessingStepsFactory);

            Postprocessing.IAggregatingLogSourceNamesProvider logSourceNamesProvider = new Postprocessing.AggregatingLogSourceNamesProvider();

            Postprocessing.InternalTracePostprocessors.Register(
                postprocessorsManager,
                userDefinedFormatsManager,
                timeSeriesTypesAccess,
                postprocessingModel
                );

            Extensibility.IPluginsManagerInternal pluginsManager = new Extensibility.PluginsManager(
                traceSourceFactory,
                telemetryCollector,
                shutdown,
                userDefinedFormatsManager,
                autoUpdateFactory.CreatePluginsIndexUpdateDownloader(),
                new Extensibility.PluginsIndex.Factory(telemetryCollector),
                changeNotification,
                autoUpdateFactory.CreateAppUpdateDownloader()
                );

            AutoUpdate.IAutoUpdater autoUpdater = autoUpdateFactory.CreateAutoUpdater(pluginsManager);

            Model expensibilityModel = new Model(
                modelSynchronizationContext,
                changeNotification,
                webContentCache,
                contentCache,
                storageManager,
                bookmarks,
                logSourcesManager,
                modelThreads,
                tempFilesManager,
                new Preprocessing.Model(
                    logSourcesPreprocessings,
                    preprocessingStepsFactory,
                    preprocessingManagerExtensionsRegistry
                    ),
                progressAggregator,
                logProviderFactoryRegistry,
                userDefinedFormatsManager,
                recentlyUsedLogs,
                progressAggregatorFactory,
                shutdown,
                webBrowserDownloader,
                postprocessingModel,
                pluginsManager,
                traceSourceFactory
                );

            tracer.Info("model creation completed");

            return(new ModelObjects
            {
                GlobalSettingsAccessor = globalSettingsAccessor,
                InstancesCounter = instancesCounter,
                Shutdown = shutdown,
                TelemetryCollector = telemetryCollector,
                FirstStartDetector = firstStartDetector,
                LaunchUrlParser = launchUrlParser,
                ChangeNotification = changeNotification,
                BookmarksFactory = bookmarksFactory,
                LogSourcesManager = logSourcesManager,
                ModelThreads = modelThreads,
                FiltersManager = filtersManager,
                Bookmarks = bookmarks,
                SearchManager = searchManager,
                FiltersFactory = filtersFactory,
                LogSourcesPreprocessings = logSourcesPreprocessings,
                UserDefinedSearches = userDefinedSearches,
                SearchHistory = searchHistory,
                ProgressAggregatorFactory = progressAggregatorFactory,
                PreprocessingStepsFactory = preprocessingStepsFactory,
                WorkspacesManager = workspacesManager,
                RecentlyUsedLogs = recentlyUsedLogs,
                LogProviderFactoryRegistry = logProviderFactoryRegistry,
                UserDefinedFormatsManager = userDefinedFormatsManager,
                PluginFormatsManager = userDefinedFormatsManager,
                FormatDefinitionsRepository = formatDefinitionsRepository,
                TempFilesManager = tempFilesManager,
                StorageManager = storageManager,
                TelemetryUploader = telemetryUploader,
                ProgressAggregator = progressAggregator,
                PostprocessorsManager = postprocessorsManager,
                ExpensibilityEntryPoint = expensibilityModel,
                AnalyticsShortNames = analyticsShortNames,
                SynchronizationContext = modelSynchronizationContext,
                AutoUpdater = autoUpdater,
                CommandLineHandler = commandLineHandler,
                LogSourceNamesProvider = logSourceNamesProvider,
                HeartBeatTimer = heartBeatTimer,
                ThreadColorsLease = threadColorsLease,
                PluginsManager = pluginsManager,
                TraceSourceFactory = traceSourceFactory
            });
        }