Dreamine.Logging.Wpf 1.0.2
Dreamine.Logging.Wpf 사용자 인터페이스 기능과 구성 요소를 제공합니다.
로딩중...
검색중...
일치하는것 없음
DreamineLoggingWpfRegistration.cs
이 파일의 문서화 페이지로 가기
1using System;
2using System.Windows;
3using Dreamine.Logging.Options;
4using Dreamine.Logging.Registration;
7using Dreamine.MVVM.Core;
8
10
20{
29 private static readonly object SyncRoot = new();
38 private static bool _isExitHandlerRegistered;
39
56 public static void Register(Action<DreamineLoggingOptions>? configure = null)
57 {
58 var options = new DreamineLoggingOptions();
59 configure?.Invoke(options);
60
61 IAsyncDisposable shutdownHandle = DreamineLoggingRegistration.Register(options);
62
63 DMContainer.RegisterSingleton<WpfLogUiDispatcher>(
64 new WpfLogUiDispatcher());
65 DMContainer.RegisterSingleton<ILogUiDispatcher>(
66 DMContainer.Resolve<WpfLogUiDispatcher>());
67
68 DMContainer.Register<DreamineLogPanelViewModel>(() =>
70 DMContainer.Resolve<Dreamine.Logging.Interfaces.IDreamineLogStore>(),
71 DMContainer.Resolve<ILogUiDispatcher>()));
72
73 RegisterShutdownHandler(shutdownHandle);
74 }
75
84 public static void Reset()
85 {
86 lock (SyncRoot)
87 {
89 }
90 }
91
108 private static void RegisterShutdownHandler(IAsyncDisposable shutdownHandle)
109 {
110 var app = Application.Current;
111 if (app is null)
112 {
113 return;
114 }
115
116 lock (SyncRoot)
117 {
119 {
120 return;
121 }
122
124 }
125
126 app.Exit += (_, _) =>
127 {
128 try
129 {
130 shutdownHandle.DisposeAsync().AsTask().GetAwaiter().GetResult();
131 }
132 catch
133 {
134 // Shutdown errors must not prevent process exit.
135 }
136 };
137 }
138}
static void Register(Action< DreamineLoggingOptions >? configure=null)