Dreamine.Hybrid.Wpf 1.0.3
`AddDreamineHybridWpf()` 내부에서 `AddWpfBlazorWebView()` 호출 및
로딩중...
검색중...
일치하는것 없음
Dreamine.Hybrid.Wpf.Hosting.DreamineBlazorServerHostedService< TRootComponent > 클래스 템플릿 참조sealed

더 자세히 ...

Dreamine.Hybrid.Wpf.Hosting.DreamineBlazorServerHostedService< TRootComponent >에 대한 상속 다이어그램 :
Dreamine.Hybrid.Wpf.Hosting.DreamineBlazorServerHostedService< TRootComponent >에 대한 협력 다이어그램:

Public 멤버 함수

 DreamineBlazorServerHostedService (IServiceProvider rootServiceProvider, IHybridMessageBus messageBus, DreamineBlazorServerHostOptions options)
async Task StartAsync (CancellationToken cancellationToken)
async Task StopAsync (CancellationToken cancellationToken)

Private 멤버 함수

void RegisterSharedServices (IServiceCollection services)

정적 Private 멤버 함수

static void RegisterViewModels (IServiceCollection services, Assembly assembly)
static bool TryGetPublishedIndexPath (string contentRootPath, HttpRequest request, out string? indexPath)

Private 속성

readonly IServiceProvider _rootServiceProvider
readonly IHybridMessageBus _messageBus
readonly DreamineBlazorServerHostOptions _options
IHost? _webHost

상세한 설명

WPF 프로세스 내부에서 Blazor Server 애플리케이션의 생명 주기를 호스팅합니다.

템플릿 파라메터
TRootComponent매핑할 루트 Razor 구성 요소 형식입니다.
타입 한정자들
TRootComponent :IComponent 

DreamineBlazorServerHostedService.cs 파일의 35 번째 라인에서 정의되었습니다.

멤버 함수 문서화

◆ DreamineBlazorServerHostedService()

Dreamine.Hybrid.Wpf.Hosting.DreamineBlazorServerHostedService< TRootComponent >.DreamineBlazorServerHostedService ( IServiceProvider rootServiceProvider,
IHybridMessageBus messageBus,
DreamineBlazorServerHostOptions options )
inline

루트 서비스 공급자, 공유 메시지 버스 및 호스트 옵션으로 새 호스팅 서비스를 초기화합니다.

매개변수
rootServiceProviderWPF 루트 서비스 공급자입니다.
messageBus공유 하이브리드 메시지 버스입니다.
optionsBlazor Server 호스트 옵션입니다.
예외
ArgumentNullException인수 중 하나가 null인 경우 발생합니다.

DreamineBlazorServerHostedService.cs 파일의 115 번째 라인에서 정의되었습니다.

119 {
120 _rootServiceProvider = rootServiceProvider ?? throw new ArgumentNullException(nameof(rootServiceProvider));
121 _messageBus = messageBus ?? throw new ArgumentNullException(nameof(messageBus));
122 _options = options ?? throw new ArgumentNullException(nameof(options));
123 }

다음을 참조함 : _messageBus, _options, _rootServiceProvider.

◆ RegisterSharedServices()

void Dreamine.Hybrid.Wpf.Hosting.DreamineBlazorServerHostedService< TRootComponent >.RegisterSharedServices ( IServiceCollection services)
inlineprivate

WPF 루트 공급자의 구성된 서비스 인스턴스를 Blazor Server 컨테이너에 공유합니다.

매개변수
services공유 서비스를 등록할 Blazor Server 서비스 컬렉션입니다.
예외
InvalidOperationException공유 서비스가 루트 공급자에 없거나 허용되지 않은 해제 가능 서비스인 경우 발생합니다.

DreamineBlazorServerHostedService.cs 파일의 300 번째 라인에서 정의되었습니다.

301 {
302 foreach (Type serviceType in _options.SharedServiceTypes)
303 {
304 object? instance = _rootServiceProvider.GetService(serviceType);
305
306 if (instance is null)
307 {
308 throw new InvalidOperationException(
309 $"Shared service '{serviceType.FullName}' was not found in the root service provider.");
310 }
311
312 if (!_options.AllowDisposableSharedServices &&
313 (instance is IDisposable || instance is IAsyncDisposable))
314 {
315 throw new InvalidOperationException(
316 $"Shared service '{serviceType.FullName}' implements IDisposable/IAsyncDisposable. " +
317 "Blazor Server would own disposal for services registered into its container. " +
318 "Share a non-disposable facade or explicitly enable AllowDisposableSharedServices when that ownership is intended.");
319 }
320
321 services.AddSingleton(serviceType, instance);
322 }
323 }

다음을 참조함 : _options, _rootServiceProvider.

다음에 의해서 참조됨 : StartAsync().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ RegisterViewModels()

void Dreamine.Hybrid.Wpf.Hosting.DreamineBlazorServerHostedService< TRootComponent >.RegisterViewModels ( IServiceCollection services,
Assembly assembly )
inlinestaticprivate

지정한 어셈블리의 공개 비추상 ViewModel 클래스를 Scoped 서비스로 등록합니다.

매개변수
servicesViewModel을 등록할 서비스 컬렉션입니다.
assembly검색할 어셈블리입니다.

DreamineBlazorServerHostedService.cs 파일의 349 번째 라인에서 정의되었습니다.

350 {
351 foreach (Type type in assembly.GetTypes()
352 .Where(type =>
353 type.IsClass &&
354 !type.IsAbstract &&
355 type.IsPublic &&
356 type.Name.EndsWith("ViewModel", StringComparison.Ordinal)))
357 {
358 services.AddScoped(type);
359 }
360 }

다음에 의해서 참조됨 : StartAsync().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ StartAsync()

async Task Dreamine.Hybrid.Wpf.Hosting.DreamineBlazorServerHostedService< TRootComponent >.StartAsync ( CancellationToken cancellationToken)
inline

Kestrel, Razor 구성 요소, 공유 서비스 및 미들웨어를 구성하고 내부 웹 호스트를 시작합니다.

매개변수
cancellationToken호스트 시작 취소 토큰입니다.
반환값
내부 웹 호스트 시작 작업입니다.

DreamineBlazorServerHostedService.cs 파일의 149 번째 라인에서 정의되었습니다.

150 {
151 Assembly blazorAssembly = typeof(TRootComponent).Assembly;
152
153 WebApplicationBuilder builder = WebApplication.CreateBuilder(new WebApplicationOptions
154 {
155 Args = Array.Empty<string>(),
156 ContentRootPath = _options.ContentRootPath,
157 ApplicationName = blazorAssembly.GetName().Name
158 });
159
160 StaticWebAssetsLoader.UseStaticWebAssets(builder.Environment, builder.Configuration);
161
162 builder.Services
163 .AddRazorComponents()
164 .AddInteractiveServerComponents();
165
166 builder.Services.AddSingleton(_messageBus);
167
168 RegisterSharedServices(builder.Services);
169 _options.ConfigureServices?.Invoke(builder.Services);
170
171 if (_options.AutoRegisterViewModels)
172 {
173 RegisterViewModels(builder.Services, blazorAssembly);
174 }
175
176 builder.WebHost.ConfigureKestrel(options =>
177 {
178 if (_options.ListenAnyIp)
179 {
180 options.ListenAnyIP(_options.Port);
181 return;
182 }
183
184 if (string.Equals(_options.Host, "localhost", StringComparison.OrdinalIgnoreCase))
185 {
186 options.ListenLocalhost(_options.Port);
187 return;
188 }
189
190 if (IPAddress.TryParse(_options.Host, out IPAddress? address))
191 {
192 options.Listen(address, _options.Port);
193 return;
194 }
195
196 options.ListenLocalhost(_options.Port);
197 });
198
199 WebApplication app = builder.Build();
200
201 app.UseStaticFiles();
202 app.Use(async (context, next) =>
203 {
204 if (TryGetPublishedIndexPath(app.Environment.ContentRootPath, context.Request, out string? indexPath))
205 {
206 context.Response.ContentType = "text/html; charset=utf-8";
207 await context.Response.SendFileAsync(indexPath!);
208 return;
209 }
210
211 await next();
212 });
213
214 // 추가 정적 파일(업로드 데이터 등)을 UseRouting 이전에 등록해야
215 // Blazor catch-all 라우터보다 먼저 처리됩니다.
216 _options.ConfigurePipeline?.Invoke(app);
217
218 app.UseRouting();
219
220 _options.ConfigurePipelineAfterRouting?.Invoke(app);
221
222 app.UseAntiforgery();
223
224 app.MapGet("/_dreamine/instance", () => _options.InstanceId);
225
226 app.MapRazorComponents<TRootComponent>()
227 .AddInteractiveServerRenderMode();
228
229 _webHost = app;
230
231 await app.StartAsync(cancellationToken);
232 }

다음을 참조함 : _messageBus, _options, _webHost, RegisterSharedServices(), RegisterViewModels(), TryGetPublishedIndexPath().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

◆ StopAsync()

async Task Dreamine.Hybrid.Wpf.Hosting.DreamineBlazorServerHostedService< TRootComponent >.StopAsync ( CancellationToken cancellationToken)
inline

실행 중인 내부 웹 호스트를 중지하고 해제합니다.

매개변수
cancellationToken호스트 중지 취소 토큰입니다.
반환값
내부 웹 호스트 중지 작업입니다.

DreamineBlazorServerHostedService.cs 파일의 258 번째 라인에서 정의되었습니다.

259 {
260 if (_webHost is null)
261 {
262 return;
263 }
264
265 try
266 {
267 await _webHost.StopAsync(cancellationToken);
268 }
269 finally
270 {
271 _webHost.Dispose();
272 _webHost = null;
273 }
274 }

다음을 참조함 : _webHost.

◆ TryGetPublishedIndexPath()

bool Dreamine.Hybrid.Wpf.Hosting.DreamineBlazorServerHostedService< TRootComponent >.TryGetPublishedIndexPath ( string contentRootPath,
HttpRequest request,
out string? indexPath )
inlinestaticprivate

안전한 디렉터리형 GET 또는 HEAD 요청을 게시된 wwwroot/index.html 파일에 매핑합니다.

매개변수
contentRootPath애플리케이션 콘텐츠 루트입니다.
request검사할 HTTP 요청입니다.
indexPath성공하면 확인된 index.html 절대 경로입니다.
반환값
안전하고 존재하는 인덱스 파일을 찾았는지 여부입니다.

DreamineBlazorServerHostedService.cs 파일의 402 번째 라인에서 정의되었습니다.

403 {
404 indexPath = null;
405
406 if (!HttpMethods.IsGet(request.Method) && !HttpMethods.IsHead(request.Method))
407 {
408 return false;
409 }
410
411 string? requestPath = request.Path.Value;
412 if (string.IsNullOrWhiteSpace(requestPath) ||
413 string.Equals(requestPath, "/", StringComparison.Ordinal) ||
414 !requestPath.EndsWith("/", StringComparison.Ordinal))
415 {
416 return false;
417 }
418
419 string[] segments = requestPath
420 .Trim('/')
421 .Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
422
423 if (segments.Length == 0 ||
424 segments.Any(segment => segment is "." or ".." || Path.GetFileName(segment) != segment))
425 {
426 return false;
427 }
428
429 string webRoot = Path.GetFullPath(Path.Combine(contentRootPath, "wwwroot"));
430 string targetDirectory = webRoot;
431 foreach (string segment in segments)
432 {
433 targetDirectory = Path.Combine(targetDirectory, segment);
434 }
435
436 string candidate = Path.GetFullPath(Path.Combine(targetDirectory, "index.html"));
437 string webRootPrefix = webRoot.EndsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal)
438 ? webRoot
439 : webRoot + Path.DirectorySeparatorChar;
440
441 if (!candidate.StartsWith(webRootPrefix, StringComparison.OrdinalIgnoreCase) || !File.Exists(candidate))
442 {
443 return false;
444 }
445
446 indexPath = candidate;
447 return true;
448 }

다음에 의해서 참조됨 : StartAsync().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

멤버 데이터 문서화

◆ _messageBus

readonly IHybridMessageBus Dreamine.Hybrid.Wpf.Hosting.DreamineBlazorServerHostedService< TRootComponent >._messageBus
private

message Bus 값을 보관합니다.

DreamineBlazorServerHostedService.cs 파일의 55 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : DreamineBlazorServerHostedService(), StartAsync().

◆ _options

readonly DreamineBlazorServerHostOptions Dreamine.Hybrid.Wpf.Hosting.DreamineBlazorServerHostedService< TRootComponent >._options
private

options 값을 보관합니다.

DreamineBlazorServerHostedService.cs 파일의 64 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : DreamineBlazorServerHostedService(), RegisterSharedServices(), StartAsync().

◆ _rootServiceProvider

readonly IServiceProvider Dreamine.Hybrid.Wpf.Hosting.DreamineBlazorServerHostedService< TRootComponent >._rootServiceProvider
private

root Service Provider 값을 보관합니다.

DreamineBlazorServerHostedService.cs 파일의 46 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : DreamineBlazorServerHostedService(), RegisterSharedServices().

◆ _webHost

IHost? Dreamine.Hybrid.Wpf.Hosting.DreamineBlazorServerHostedService< TRootComponent >._webHost
private

web Host 값을 보관합니다.

DreamineBlazorServerHostedService.cs 파일의 73 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : StartAsync(), StopAsync().


이 클래스에 대한 문서화 페이지는 다음의 파일로부터 생성되었습니다.: