/
githubmirror
/
aspnetcore
Обзор
Документация
Войти
/
githubmirror
/
aspnetcore
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Components/Shared/test/AutoRenderComponent.cs
43 строки
1 KB
Shreyas Jejurkar
chore : Remove unwanted `using` statement (#39176)
02 янв 2022, 17:39
Не верифицирован
02 янв 2022, 17:39
c85baf8
Код
Авторство
О чём код?
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Runtime.ExceptionServices; using Microsoft.AspNetCore.Components.Rendering; namespace Microsoft.AspNetCore.Components.Test.Helpers; public abstract class AutoRenderComponent : IComponent { private RenderHandle _renderHandle; public void Attach(RenderHandle renderHandle) { _renderHandle = renderHandle; } public virtual Task SetParametersAsync(ParameterView parameters) { parameters.SetParameterProperties(this); TriggerRender(); return Task.CompletedTask; } // We do it this way so that we don't have to be doing renderer.Invoke on each and every test. public void TriggerRender() { var t = _renderHandle.Dispatcher.InvokeAsync(() => _renderHandle.Render(BuildRenderTree)); // This should always be run synchronously Assert.True(t.IsCompleted); if (t.IsFaulted) { var exception = t.Exception.Flatten().InnerException; while (exception is AggregateException e) { exception = e.InnerException; } ExceptionDispatchInfo.Capture(exception).Throw(); } } protected abstract void BuildRenderTree(RenderTreeBuilder builder); }