/// <summary> /// Initializes a new instance of the <see cref="DiagnosticInfosViewModel"/> class. /// </summary> /// <param name="editor">The <see cref="IEditor"/>.</param> /// <param name="diagnosticProvider">The <see cref="IDiagnosticProvider"/>.</param> public DiagnosticInfosViewModel( IEditor editor, IDispatcherServiceFactory dispatcherServiceFactory, IDiagnosticProvider diagnosticProvider) { _diagnosticProvider = diagnosticProvider ?? throw new ArgumentNullException(nameof(diagnosticProvider)); _dispatcherService = dispatcherServiceFactory.Create(); Editor = editor ?? throw new ArgumentNullException(nameof(editor)); WeakEventManager <IDiagnosticProvider, DiagnosticsChangedEventArgs> .AddHandler(_diagnosticProvider, nameof(IDiagnosticProvider.DiagnosticsChanged), OnDiagnosticsChanged); Editor.FoldingManager.Expanded += OnCodeExpanded; Editor.FoldingManager.Collapsed += OnCodeCollapsed; OnDiagnosticsChanged(this, new DiagnosticsChangedEventArgs(_diagnosticProvider.CurrentDiagnostics)); }
/// <summary> /// Initializes a new instance of the <see cref="CodeStructureViewModel"/> class. /// </summary> /// <param name="editor">The <see cref="IEditor"/>.</param> /// <param name="diagnosticProvider">The <see cref="IDiagnosticProvider"/>.</param> /// <param name="documentAnalyzerService">The <see cref="IDocumentAnalyzerService"/>.</param> /// <param name="spaceReservation">The <see cref="IAdornmentSpaceReservation"/>.</param> public CodeStructureViewModel( IEditor editor, IDiagnosticProvider diagnosticProvider, IDocumentAnalyzerService documentAnalyzerService, IAdornmentSpaceReservation spaceReservation, IDispatcherServiceFactory dispatcherServiceFactory) { _editor = editor; _diagnosticProvider = diagnosticProvider ?? throw new ArgumentNullException(nameof(diagnosticProvider)); _documentAnalyzerService = documentAnalyzerService ?? throw new ArgumentNullException(nameof(documentAnalyzerService)); _dispatcherService = dispatcherServiceFactory.Create(); WeakEventManager <IDiagnosticProvider, DiagnosticsChangedEventArgs> .AddHandler(_diagnosticProvider, nameof(IDiagnosticProvider.DiagnosticsChanged), OnDiagnosticsChanged); WeakEventManager <IDocumentAnalyzerService, EventArgs> .AddHandler(_documentAnalyzerService, nameof(IDocumentAnalyzerService.AnalysisFinished), OnAnalysisFinished); SpaceReservation = spaceReservation; }