Blazor API Review: Parameters (#12547)
* Blazor API Review: Parameters Part of #11610
This commit is contained in:
parent
5631b97d12
commit
bfd4305fd8
|
|
@ -68,7 +68,7 @@ namespace Test
|
||||||
{
|
{
|
||||||
public class MyComponent : ComponentBase, IComponent
|
public class MyComponent : ComponentBase, IComponent
|
||||||
{
|
{
|
||||||
Task IComponent.SetParametersAsync(ParameterCollection parameters)
|
Task IComponent.SetParametersAsync(ParameterView parameters)
|
||||||
{
|
{
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
@ -142,7 +142,7 @@ namespace Test
|
||||||
{
|
{
|
||||||
public class MyComponent : ComponentBase, IComponent
|
public class MyComponent : ComponentBase, IComponent
|
||||||
{
|
{
|
||||||
Task IComponent.SetParametersAsync(ParameterCollection parameters)
|
Task IComponent.SetParametersAsync(ParameterView parameters)
|
||||||
{
|
{
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -165,7 +165,7 @@ namespace Test
|
||||||
{
|
{
|
||||||
public class MyComponent : ComponentBase, IComponent
|
public class MyComponent : ComponentBase, IComponent
|
||||||
{
|
{
|
||||||
Task IComponent.SetParametersAsync(ParameterCollection parameters)
|
Task IComponent.SetParametersAsync(ParameterView parameters)
|
||||||
{
|
{
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -153,7 +153,7 @@ namespace Microsoft.AspNetCore.Blazor.Build.Test
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task SetParametersAsync(ParameterCollection parameters)
|
public Task SetParametersAsync(ParameterView parameters)
|
||||||
{
|
{
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -385,7 +385,7 @@ namespace Microsoft.AspNetCore.Blazor.Build.Test
|
||||||
protected private RenderTreeFrame[] GetRenderTree(TestRenderer renderer, IComponent component)
|
protected private RenderTreeFrame[] GetRenderTree(TestRenderer renderer, IComponent component)
|
||||||
{
|
{
|
||||||
renderer.AttachComponent(component);
|
renderer.AttachComponent(component);
|
||||||
var task = renderer.Dispatcher.InvokeAsync(() => component.SetParametersAsync(ParameterCollection.Empty));
|
var task = renderer.Dispatcher.InvokeAsync(() => component.SetParametersAsync(ParameterView.Empty));
|
||||||
// we will have to change this method if we add a test that does actual async work.
|
// we will have to change this method if we add a test that does actual async work.
|
||||||
Assert.True(task.Status.HasFlag(TaskStatus.RanToCompletion) || task.Status.HasFlag(TaskStatus.Faulted));
|
Assert.True(task.Status.HasFlag(TaskStatus.RanToCompletion) || task.Status.HasFlag(TaskStatus.Faulted));
|
||||||
if (task.IsFaulted)
|
if (task.IsFaulted)
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,7 @@ namespace Microsoft.AspNetCore.Components
|
||||||
[Microsoft.AspNetCore.Components.ParameterAttribute]
|
[Microsoft.AspNetCore.Components.ParameterAttribute]
|
||||||
public T Value { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
|
public T Value { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
|
||||||
public void Attach(Microsoft.AspNetCore.Components.RenderHandle renderHandle) { }
|
public void Attach(Microsoft.AspNetCore.Components.RenderHandle renderHandle) { }
|
||||||
public System.Threading.Tasks.Task SetParametersAsync(Microsoft.AspNetCore.Components.ParameterCollection parameters) { throw null; }
|
public System.Threading.Tasks.Task SetParametersAsync(Microsoft.AspNetCore.Components.ParameterView parameters) { throw null; }
|
||||||
}
|
}
|
||||||
public abstract partial class ComponentBase : Microsoft.AspNetCore.Components.IComponent, Microsoft.AspNetCore.Components.IHandleAfterRender, Microsoft.AspNetCore.Components.IHandleEvent
|
public abstract partial class ComponentBase : Microsoft.AspNetCore.Components.IComponent, Microsoft.AspNetCore.Components.IHandleAfterRender, Microsoft.AspNetCore.Components.IHandleEvent
|
||||||
{
|
{
|
||||||
|
|
@ -134,7 +134,7 @@ namespace Microsoft.AspNetCore.Components
|
||||||
protected virtual System.Threading.Tasks.Task OnInitializedAsync() { throw null; }
|
protected virtual System.Threading.Tasks.Task OnInitializedAsync() { throw null; }
|
||||||
protected virtual void OnParametersSet() { }
|
protected virtual void OnParametersSet() { }
|
||||||
protected virtual System.Threading.Tasks.Task OnParametersSetAsync() { throw null; }
|
protected virtual System.Threading.Tasks.Task OnParametersSetAsync() { throw null; }
|
||||||
public virtual System.Threading.Tasks.Task SetParametersAsync(Microsoft.AspNetCore.Components.ParameterCollection parameters) { throw null; }
|
public virtual System.Threading.Tasks.Task SetParametersAsync(Microsoft.AspNetCore.Components.ParameterView parameters) { throw null; }
|
||||||
protected virtual bool ShouldRender() { throw null; }
|
protected virtual bool ShouldRender() { throw null; }
|
||||||
protected void StateHasChanged() { }
|
protected void StateHasChanged() { }
|
||||||
}
|
}
|
||||||
|
|
@ -238,7 +238,7 @@ namespace Microsoft.AspNetCore.Components
|
||||||
public partial interface IComponent
|
public partial interface IComponent
|
||||||
{
|
{
|
||||||
void Attach(Microsoft.AspNetCore.Components.RenderHandle renderHandle);
|
void Attach(Microsoft.AspNetCore.Components.RenderHandle renderHandle);
|
||||||
System.Threading.Tasks.Task SetParametersAsync(Microsoft.AspNetCore.Components.ParameterCollection parameters);
|
System.Threading.Tasks.Task SetParametersAsync(Microsoft.AspNetCore.Components.ParameterView parameters);
|
||||||
}
|
}
|
||||||
public partial interface IComponentContext
|
public partial interface IComponentContext
|
||||||
{
|
{
|
||||||
|
|
@ -309,16 +309,7 @@ namespace Microsoft.AspNetCore.Components
|
||||||
[Microsoft.AspNetCore.Components.ParameterAttribute]
|
[Microsoft.AspNetCore.Components.ParameterAttribute]
|
||||||
public System.Collections.Generic.IDictionary<string, object> PageParameters { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
|
public System.Collections.Generic.IDictionary<string, object> PageParameters { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
|
||||||
public void Attach(Microsoft.AspNetCore.Components.RenderHandle renderHandle) { }
|
public void Attach(Microsoft.AspNetCore.Components.RenderHandle renderHandle) { }
|
||||||
public System.Threading.Tasks.Task SetParametersAsync(Microsoft.AspNetCore.Components.ParameterCollection parameters) { throw null; }
|
public System.Threading.Tasks.Task SetParametersAsync(Microsoft.AspNetCore.Components.ParameterView parameters) { throw null; }
|
||||||
}
|
|
||||||
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
|
|
||||||
public readonly partial struct Parameter
|
|
||||||
{
|
|
||||||
private readonly object _dummy;
|
|
||||||
private readonly int _dummyPrimitive;
|
|
||||||
public bool Cascading { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
|
|
||||||
public string Name { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
|
|
||||||
public object Value { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
|
|
||||||
}
|
}
|
||||||
[System.AttributeUsageAttribute(System.AttributeTargets.Property, AllowMultiple=false, Inherited=true)]
|
[System.AttributeUsageAttribute(System.AttributeTargets.Property, AllowMultiple=false, Inherited=true)]
|
||||||
public sealed partial class ParameterAttribute : System.Attribute
|
public sealed partial class ParameterAttribute : System.Attribute
|
||||||
|
|
@ -327,29 +318,35 @@ namespace Microsoft.AspNetCore.Components
|
||||||
public bool CaptureUnmatchedValues { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
|
public bool CaptureUnmatchedValues { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
|
||||||
}
|
}
|
||||||
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
|
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
|
||||||
public readonly partial struct ParameterCollection
|
public readonly partial struct ParameterValue
|
||||||
{
|
{
|
||||||
private readonly object _dummy;
|
private readonly object _dummy;
|
||||||
private readonly int _dummyPrimitive;
|
private readonly int _dummyPrimitive;
|
||||||
public static Microsoft.AspNetCore.Components.ParameterCollection Empty { get { throw null; } }
|
public bool Cascading { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
|
||||||
public static Microsoft.AspNetCore.Components.ParameterCollection FromDictionary(System.Collections.Generic.IDictionary<string, object> parameters) { throw null; }
|
public string Name { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
|
||||||
public Microsoft.AspNetCore.Components.ParameterEnumerator GetEnumerator() { throw null; }
|
public object Value { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
|
||||||
public T GetValueOrDefault<T>(string parameterName) { throw null; }
|
|
||||||
public T GetValueOrDefault<T>(string parameterName, T defaultValue) { throw null; }
|
|
||||||
public System.Collections.Generic.IReadOnlyDictionary<string, object> ToDictionary() { throw null; }
|
|
||||||
public bool TryGetValue<T>(string parameterName, out T result) { throw null; }
|
|
||||||
}
|
|
||||||
public static partial class ParameterCollectionExtensions
|
|
||||||
{
|
|
||||||
public static void SetParameterProperties(this in Microsoft.AspNetCore.Components.ParameterCollection parameterCollection, object target) { }
|
|
||||||
}
|
}
|
||||||
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
|
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
|
||||||
public partial struct ParameterEnumerator
|
public readonly partial struct ParameterView
|
||||||
{
|
{
|
||||||
private object _dummy;
|
private readonly object _dummy;
|
||||||
private int _dummyPrimitive;
|
private readonly int _dummyPrimitive;
|
||||||
public Microsoft.AspNetCore.Components.Parameter Current { get { throw null; } }
|
public static Microsoft.AspNetCore.Components.ParameterView Empty { get { throw null; } }
|
||||||
public bool MoveNext() { throw null; }
|
public static Microsoft.AspNetCore.Components.ParameterView FromDictionary(System.Collections.Generic.IDictionary<string, object> parameters) { throw null; }
|
||||||
|
public Microsoft.AspNetCore.Components.ParameterView.Enumerator GetEnumerator() { throw null; }
|
||||||
|
public T GetValueOrDefault<T>(string parameterName) { throw null; }
|
||||||
|
public T GetValueOrDefault<T>(string parameterName, T defaultValue) { throw null; }
|
||||||
|
public void SetParameterProperties(object target) { }
|
||||||
|
public System.Collections.Generic.IReadOnlyDictionary<string, object> ToDictionary() { throw null; }
|
||||||
|
public bool TryGetValue<T>(string parameterName, out T result) { throw null; }
|
||||||
|
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
|
||||||
|
public partial struct Enumerator
|
||||||
|
{
|
||||||
|
private object _dummy;
|
||||||
|
private int _dummyPrimitive;
|
||||||
|
public Microsoft.AspNetCore.Components.ParameterValue Current { get { throw null; } }
|
||||||
|
public bool MoveNext() { throw null; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public delegate void RenderFragment(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder);
|
public delegate void RenderFragment(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder);
|
||||||
public delegate Microsoft.AspNetCore.Components.RenderFragment RenderFragment<T>(T value);
|
public delegate Microsoft.AspNetCore.Components.RenderFragment RenderFragment<T>(T value);
|
||||||
|
|
@ -502,8 +499,8 @@ namespace Microsoft.AspNetCore.Components.Rendering
|
||||||
public override Microsoft.AspNetCore.Components.Dispatcher Dispatcher { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
|
public override Microsoft.AspNetCore.Components.Dispatcher Dispatcher { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
|
||||||
protected override void HandleException(System.Exception exception) { }
|
protected override void HandleException(System.Exception exception) { }
|
||||||
[System.Diagnostics.DebuggerStepThroughAttribute]
|
[System.Diagnostics.DebuggerStepThroughAttribute]
|
||||||
public System.Threading.Tasks.Task<Microsoft.AspNetCore.Components.Rendering.ComponentRenderedText> RenderComponentAsync(System.Type componentType, Microsoft.AspNetCore.Components.ParameterCollection initialParameters) { throw null; }
|
public System.Threading.Tasks.Task<Microsoft.AspNetCore.Components.Rendering.ComponentRenderedText> RenderComponentAsync(System.Type componentType, Microsoft.AspNetCore.Components.ParameterView initialParameters) { throw null; }
|
||||||
public System.Threading.Tasks.Task<Microsoft.AspNetCore.Components.Rendering.ComponentRenderedText> RenderComponentAsync<TComponent>(Microsoft.AspNetCore.Components.ParameterCollection initialParameters) where TComponent : Microsoft.AspNetCore.Components.IComponent { throw null; }
|
public System.Threading.Tasks.Task<Microsoft.AspNetCore.Components.Rendering.ComponentRenderedText> RenderComponentAsync<TComponent>(Microsoft.AspNetCore.Components.ParameterView initialParameters) where TComponent : Microsoft.AspNetCore.Components.IComponent { throw null; }
|
||||||
protected override System.Threading.Tasks.Task UpdateDisplayAsync(in Microsoft.AspNetCore.Components.Rendering.RenderBatch renderBatch) { throw null; }
|
protected override System.Threading.Tasks.Task UpdateDisplayAsync(in Microsoft.AspNetCore.Components.Rendering.RenderBatch renderBatch) { throw null; }
|
||||||
}
|
}
|
||||||
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
|
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
|
||||||
|
|
@ -529,7 +526,7 @@ namespace Microsoft.AspNetCore.Components.Rendering
|
||||||
protected Microsoft.AspNetCore.Components.IComponent InstantiateComponent(System.Type componentType) { throw null; }
|
protected Microsoft.AspNetCore.Components.IComponent InstantiateComponent(System.Type componentType) { throw null; }
|
||||||
protected System.Threading.Tasks.Task RenderRootComponentAsync(int componentId) { throw null; }
|
protected System.Threading.Tasks.Task RenderRootComponentAsync(int componentId) { throw null; }
|
||||||
[System.Diagnostics.DebuggerStepThroughAttribute]
|
[System.Diagnostics.DebuggerStepThroughAttribute]
|
||||||
protected System.Threading.Tasks.Task RenderRootComponentAsync(int componentId, Microsoft.AspNetCore.Components.ParameterCollection initialParameters) { throw null; }
|
protected System.Threading.Tasks.Task RenderRootComponentAsync(int componentId, Microsoft.AspNetCore.Components.ParameterView initialParameters) { throw null; }
|
||||||
protected abstract System.Threading.Tasks.Task UpdateDisplayAsync(in Microsoft.AspNetCore.Components.Rendering.RenderBatch renderBatch);
|
protected abstract System.Threading.Tasks.Task UpdateDisplayAsync(in Microsoft.AspNetCore.Components.Rendering.RenderBatch renderBatch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -663,6 +660,6 @@ namespace Microsoft.AspNetCore.Components.Routing
|
||||||
public void Dispose() { }
|
public void Dispose() { }
|
||||||
System.Threading.Tasks.Task Microsoft.AspNetCore.Components.IHandleAfterRender.OnAfterRenderAsync() { throw null; }
|
System.Threading.Tasks.Task Microsoft.AspNetCore.Components.IHandleAfterRender.OnAfterRenderAsync() { throw null; }
|
||||||
protected virtual void Render(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder, System.Type handler, System.Collections.Generic.IDictionary<string, object> parameters) { }
|
protected virtual void Render(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder, System.Type handler, System.Collections.Generic.IDictionary<string, object> parameters) { }
|
||||||
public System.Threading.Tasks.Task SetParametersAsync(Microsoft.AspNetCore.Components.ParameterCollection parameters) { throw null; }
|
public System.Threading.Tasks.Task SetParametersAsync(Microsoft.AspNetCore.Components.ParameterView parameters) { throw null; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using Microsoft.AspNetCore.Components.Reflection;
|
||||||
using Microsoft.AspNetCore.Components.Rendering;
|
using Microsoft.AspNetCore.Components.Rendering;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
|
|
@ -89,7 +90,7 @@ namespace Microsoft.AspNetCore.Components
|
||||||
private static ReflectedCascadingParameterInfo[] CreateReflectedCascadingParameterInfos(Type componentType)
|
private static ReflectedCascadingParameterInfo[] CreateReflectedCascadingParameterInfos(Type componentType)
|
||||||
{
|
{
|
||||||
List<ReflectedCascadingParameterInfo> result = null;
|
List<ReflectedCascadingParameterInfo> result = null;
|
||||||
var candidateProps = ParameterCollectionExtensions.GetCandidateBindableProperties(componentType);
|
var candidateProps = ComponentProperties.GetCandidateBindableProperties(componentType);
|
||||||
foreach (var prop in candidateProps)
|
foreach (var prop in candidateProps)
|
||||||
{
|
{
|
||||||
var attribute = prop.GetCustomAttribute<CascadingParameterAttribute>();
|
var attribute = prop.GetCustomAttribute<CascadingParameterAttribute>();
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ namespace Microsoft.AspNetCore.Components
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public Task SetParametersAsync(ParameterCollection parameters)
|
public Task SetParametersAsync(ParameterView parameters)
|
||||||
{
|
{
|
||||||
// Implementing the parameter binding manually, instead of just calling
|
// Implementing the parameter binding manually, instead of just calling
|
||||||
// parameters.SetParameterProperties(this), is just a very slight perf optimization
|
// parameters.SetParameterProperties(this), is just a very slight perf optimization
|
||||||
|
|
@ -110,7 +110,7 @@ namespace Microsoft.AspNetCore.Components
|
||||||
// because it serves no useful purpose to have a <CascadingValue> otherwise.
|
// because it serves no useful purpose to have a <CascadingValue> otherwise.
|
||||||
if (!hasSuppliedValue)
|
if (!hasSuppliedValue)
|
||||||
{
|
{
|
||||||
throw new ArgumentException($"Missing required parameter '{nameof(Value)}' for component '{nameof(Parameter)}'.");
|
throw new ArgumentException($"Missing required parameter '{nameof(Value)}' for component '{GetType().Name}'.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rendering is most efficient when things are queued from rootmost to leafmost.
|
// Rendering is most efficient when things are queued from rootmost to leafmost.
|
||||||
|
|
|
||||||
|
|
@ -175,7 +175,7 @@ namespace Microsoft.AspNetCore.Components
|
||||||
/// Method invoked to apply initial or updated parameters to the component.
|
/// Method invoked to apply initial or updated parameters to the component.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="parameters">The parameters to apply.</param>
|
/// <param name="parameters">The parameters to apply.</param>
|
||||||
public virtual Task SetParametersAsync(ParameterCollection parameters)
|
public virtual Task SetParametersAsync(ParameterView parameters)
|
||||||
{
|
{
|
||||||
parameters.SetParameterProperties(this);
|
parameters.SetParameterProperties(this);
|
||||||
if (!_initialized)
|
if (!_initialized)
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,6 @@ namespace Microsoft.AspNetCore.Components
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="parameters">The parameters.</param>
|
/// <param name="parameters">The parameters.</param>
|
||||||
/// <returns>A <see cref="Task"/> that completes when the component has finished updating and rendering itself.</returns>
|
/// <returns>A <see cref="Task"/> that completes when the component has finished updating and rendering itself.</returns>
|
||||||
Task SetParametersAsync(ParameterCollection parameters);
|
Task SetParametersAsync(ParameterView parameters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ namespace Microsoft.AspNetCore.Components
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public Task SetParametersAsync(ParameterCollection parameters)
|
public Task SetParametersAsync(ParameterView parameters)
|
||||||
{
|
{
|
||||||
parameters.SetParameterProperties(this);
|
parameters.SetParameterProperties(this);
|
||||||
Render();
|
Render();
|
||||||
|
|
|
||||||
|
|
@ -1,137 +0,0 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Components.RenderTree;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Components
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// An enumerator that iterates through a <see cref="ParameterCollection"/>.
|
|
||||||
/// </summary>
|
|
||||||
public struct ParameterEnumerator
|
|
||||||
{
|
|
||||||
private RenderTreeFrameParameterEnumerator _directParamsEnumerator;
|
|
||||||
private CascadingParameterEnumerator _cascadingParameterEnumerator;
|
|
||||||
private bool _isEnumeratingDirectParams;
|
|
||||||
|
|
||||||
internal ParameterEnumerator(RenderTreeFrame[] frames, int ownerIndex, IReadOnlyList<CascadingParameterState> cascadingParameters)
|
|
||||||
{
|
|
||||||
_directParamsEnumerator = new RenderTreeFrameParameterEnumerator(frames, ownerIndex);
|
|
||||||
_cascadingParameterEnumerator = new CascadingParameterEnumerator(cascadingParameters);
|
|
||||||
_isEnumeratingDirectParams = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the current value of the enumerator.
|
|
||||||
/// </summary>
|
|
||||||
public Parameter Current => _isEnumeratingDirectParams
|
|
||||||
? _directParamsEnumerator.Current
|
|
||||||
: _cascadingParameterEnumerator.Current;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Instructs the enumerator to move to the next value in the sequence.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A flag to indicate whether or not there is a next value.</returns>
|
|
||||||
public bool MoveNext()
|
|
||||||
{
|
|
||||||
if (_isEnumeratingDirectParams)
|
|
||||||
{
|
|
||||||
if (_directParamsEnumerator.MoveNext())
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_isEnumeratingDirectParams = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return _cascadingParameterEnumerator.MoveNext();
|
|
||||||
}
|
|
||||||
|
|
||||||
struct RenderTreeFrameParameterEnumerator
|
|
||||||
{
|
|
||||||
private readonly RenderTreeFrame[] _frames;
|
|
||||||
private readonly int _ownerIndex;
|
|
||||||
private readonly int _ownerDescendantsEndIndexExcl;
|
|
||||||
private int _currentIndex;
|
|
||||||
private Parameter _current;
|
|
||||||
|
|
||||||
internal RenderTreeFrameParameterEnumerator(RenderTreeFrame[] frames, int ownerIndex)
|
|
||||||
{
|
|
||||||
_frames = frames;
|
|
||||||
_ownerIndex = ownerIndex;
|
|
||||||
_ownerDescendantsEndIndexExcl = ownerIndex + _frames[ownerIndex].ElementSubtreeLength;
|
|
||||||
_currentIndex = ownerIndex;
|
|
||||||
_current = default;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Parameter Current => _current;
|
|
||||||
|
|
||||||
public bool MoveNext()
|
|
||||||
{
|
|
||||||
// Stop iteration if you get to the end of the owner's descendants...
|
|
||||||
var nextIndex = _currentIndex + 1;
|
|
||||||
if (nextIndex == _ownerDescendantsEndIndexExcl)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ... or if you get to its first non-attribute descendant (because attributes
|
|
||||||
// are always before any other type of descendant)
|
|
||||||
if (_frames[nextIndex].FrameType != RenderTreeFrameType.Attribute)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
_currentIndex = nextIndex;
|
|
||||||
|
|
||||||
ref var frame = ref _frames[_currentIndex];
|
|
||||||
_current = new Parameter(frame.AttributeName, frame.AttributeValue, false);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct CascadingParameterEnumerator
|
|
||||||
{
|
|
||||||
private readonly IReadOnlyList<CascadingParameterState> _cascadingParameters;
|
|
||||||
private int _currentIndex;
|
|
||||||
private Parameter _current;
|
|
||||||
|
|
||||||
public CascadingParameterEnumerator(IReadOnlyList<CascadingParameterState> cascadingParameters)
|
|
||||||
{
|
|
||||||
_cascadingParameters = cascadingParameters;
|
|
||||||
_currentIndex = -1;
|
|
||||||
_current = default;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Parameter Current => _current;
|
|
||||||
|
|
||||||
public bool MoveNext()
|
|
||||||
{
|
|
||||||
// Bail out early if there are no cascading parameters
|
|
||||||
if (_cascadingParameters == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var nextIndex = _currentIndex + 1;
|
|
||||||
if (nextIndex < _cascadingParameters.Count)
|
|
||||||
{
|
|
||||||
_currentIndex = nextIndex;
|
|
||||||
|
|
||||||
var state = _cascadingParameters[_currentIndex];
|
|
||||||
_current = new Parameter(state.LocalValueName, state.ValueSupplier.CurrentValue, true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -7,8 +7,15 @@ namespace Microsoft.AspNetCore.Components
|
||||||
/// Represents a single parameter supplied to an <see cref="IComponent"/>
|
/// Represents a single parameter supplied to an <see cref="IComponent"/>
|
||||||
/// by its parent in the render tree.
|
/// by its parent in the render tree.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly struct Parameter
|
public readonly struct ParameterValue
|
||||||
{
|
{
|
||||||
|
internal ParameterValue(string name, object value, bool cascading)
|
||||||
|
{
|
||||||
|
Name = name;
|
||||||
|
Value = value;
|
||||||
|
Cascading = cascading;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the name of the parameter.
|
/// Gets the name of the parameter.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -24,12 +31,5 @@ namespace Microsoft.AspNetCore.Components
|
||||||
/// was supplied by a <see cref="CascadingValue{T}"/>.
|
/// was supplied by a <see cref="CascadingValue{T}"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Cascading { get; }
|
public bool Cascading { get; }
|
||||||
|
|
||||||
internal Parameter(string name, object value, bool cascading)
|
|
||||||
{
|
|
||||||
Name = name;
|
|
||||||
Value = value;
|
|
||||||
Cascading = cascading;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Microsoft.AspNetCore.Components.Reflection;
|
||||||
using Microsoft.AspNetCore.Components.RenderTree;
|
using Microsoft.AspNetCore.Components.RenderTree;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Components
|
namespace Microsoft.AspNetCore.Components
|
||||||
|
|
@ -11,27 +12,26 @@ namespace Microsoft.AspNetCore.Components
|
||||||
/// Represents a collection of parameters supplied to an <see cref="IComponent"/>
|
/// Represents a collection of parameters supplied to an <see cref="IComponent"/>
|
||||||
/// by its parent in the render tree.
|
/// by its parent in the render tree.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly struct ParameterCollection
|
public readonly struct ParameterView
|
||||||
{
|
{
|
||||||
private const string GeneratedParameterCollectionElementName = "__ARTIFICIAL_PARAMETER_COLLECTION";
|
private const string GeneratedParameterViewElementName = "__ARTIFICIAL_PARAMETER_VIEW";
|
||||||
private static readonly RenderTreeFrame[] _emptyCollectionFrames = new RenderTreeFrame[]
|
private static readonly RenderTreeFrame[] _emptyFrames = new RenderTreeFrame[]
|
||||||
{
|
{
|
||||||
RenderTreeFrame.Element(0, string.Empty).WithComponentSubtreeLength(1)
|
RenderTreeFrame.Element(0, string.Empty).WithComponentSubtreeLength(1)
|
||||||
};
|
};
|
||||||
|
|
||||||
private static readonly ParameterCollection _emptyCollection
|
private static readonly ParameterView _empty = new ParameterView(_emptyFrames, 0, null);
|
||||||
= new ParameterCollection(_emptyCollectionFrames, 0, null);
|
|
||||||
|
|
||||||
private readonly RenderTreeFrame[] _frames;
|
private readonly RenderTreeFrame[] _frames;
|
||||||
private readonly int _ownerIndex;
|
private readonly int _ownerIndex;
|
||||||
private readonly IReadOnlyList<CascadingParameterState> _cascadingParametersOrNull;
|
private readonly IReadOnlyList<CascadingParameterState> _cascadingParametersOrNull;
|
||||||
|
|
||||||
internal ParameterCollection(RenderTreeFrame[] frames, int ownerIndex)
|
internal ParameterView(RenderTreeFrame[] frames, int ownerIndex)
|
||||||
: this(frames, ownerIndex, null)
|
: this(frames, ownerIndex, null)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
private ParameterCollection(RenderTreeFrame[] frames, int ownerIndex, IReadOnlyList<CascadingParameterState> cascadingParametersOrNull)
|
private ParameterView(RenderTreeFrame[] frames, int ownerIndex, IReadOnlyList<CascadingParameterState> cascadingParametersOrNull)
|
||||||
{
|
{
|
||||||
_frames = frames;
|
_frames = frames;
|
||||||
_ownerIndex = ownerIndex;
|
_ownerIndex = ownerIndex;
|
||||||
|
|
@ -39,16 +39,16 @@ namespace Microsoft.AspNetCore.Components
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets an empty <see cref="ParameterCollection"/>.
|
/// Gets an empty <see cref="ParameterView"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static ParameterCollection Empty => _emptyCollection;
|
public static ParameterView Empty => _empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns an enumerator that iterates through the <see cref="ParameterCollection"/>.
|
/// Returns an enumerator that iterates through the <see cref="ParameterView"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The enumerator.</returns>
|
/// <returns>The enumerator.</returns>
|
||||||
public ParameterEnumerator GetEnumerator()
|
public Enumerator GetEnumerator()
|
||||||
=> new ParameterEnumerator(_frames, _ownerIndex, _cascadingParametersOrNull);
|
=> new Enumerator(_frames, _ownerIndex, _cascadingParametersOrNull);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the value of the parameter with the specified name.
|
/// Gets the value of the parameter with the specified name.
|
||||||
|
|
@ -94,9 +94,9 @@ namespace Microsoft.AspNetCore.Components
|
||||||
=> TryGetValue<T>(parameterName, out T result) ? result : defaultValue;
|
=> TryGetValue<T>(parameterName, out T result) ? result : defaultValue;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a dictionary populated with the contents of the <see cref="ParameterCollection"/>.
|
/// Returns a dictionary populated with the contents of the <see cref="ParameterView"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>A dictionary populated with the contents of the <see cref="ParameterCollection"/>.</returns>
|
/// <returns>A dictionary populated with the contents of the <see cref="ParameterView"/>.</returns>
|
||||||
public IReadOnlyDictionary<string, object> ToDictionary()
|
public IReadOnlyDictionary<string, object> ToDictionary()
|
||||||
{
|
{
|
||||||
var result = new Dictionary<string, object>();
|
var result = new Dictionary<string, object>();
|
||||||
|
|
@ -107,13 +107,13 @@ namespace Microsoft.AspNetCore.Components
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal ParameterCollection WithCascadingParameters(IReadOnlyList<CascadingParameterState> cascadingParameters)
|
internal ParameterView WithCascadingParameters(IReadOnlyList<CascadingParameterState> cascadingParameters)
|
||||||
=> new ParameterCollection(_frames, _ownerIndex, cascadingParameters);
|
=> new ParameterView(_frames, _ownerIndex, cascadingParameters);
|
||||||
|
|
||||||
// It's internal because there isn't a known use case for user code comparing
|
// It's internal because there isn't a known use case for user code comparing
|
||||||
// ParameterCollection instances, and even if there was, it's unlikely it should
|
// ParameterView instances, and even if there was, it's unlikely it should
|
||||||
// use these equality rules which are designed for their effect on rendering.
|
// use these equality rules which are designed for their effect on rendering.
|
||||||
internal bool DefinitelyEquals(ParameterCollection oldParameters)
|
internal bool DefinitelyEquals(ParameterView oldParameters)
|
||||||
{
|
{
|
||||||
// In general we can't detect mutations on arbitrary objects. We can't trust
|
// In general we can't detect mutations on arbitrary objects. We can't trust
|
||||||
// things like .Equals or .GetHashCode because they usually only tell us about
|
// things like .Equals or .GetHashCode because they usually only tell us about
|
||||||
|
|
@ -187,7 +187,7 @@ namespace Microsoft.AspNetCore.Components
|
||||||
}
|
}
|
||||||
|
|
||||||
// We need to prefix the captured frames with an "owner" frame that
|
// We need to prefix the captured frames with an "owner" frame that
|
||||||
// describes the length of the buffer so that ParameterCollection
|
// describes the length of the buffer so that ParameterView
|
||||||
// knows how far to iterate through it.
|
// knows how far to iterate through it.
|
||||||
var owner = RenderTreeFrame.PlaceholderChildComponentWithSubtreeLength(1 + numEntries);
|
var owner = RenderTreeFrame.PlaceholderChildComponentWithSubtreeLength(1 + numEntries);
|
||||||
builder.Append(owner);
|
builder.Append(owner);
|
||||||
|
|
@ -199,14 +199,14 @@ namespace Microsoft.AspNetCore.Components
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new <see cref="ParameterCollection"/> from the given <see cref="IDictionary{TKey, TValue}"/>.
|
/// Creates a new <see cref="ParameterView"/> from the given <see cref="IDictionary{TKey, TValue}"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="parameters">The <see cref="IDictionary{TKey, TValue}"/> with the parameters.</param>
|
/// <param name="parameters">The <see cref="IDictionary{TKey, TValue}"/> with the parameters.</param>
|
||||||
/// <returns>A <see cref="ParameterCollection"/>.</returns>
|
/// <returns>A <see cref="ParameterView"/>.</returns>
|
||||||
public static ParameterCollection FromDictionary(IDictionary<string, object> parameters)
|
public static ParameterView FromDictionary(IDictionary<string, object> parameters)
|
||||||
{
|
{
|
||||||
var frames = new RenderTreeFrame[parameters.Count + 1];
|
var frames = new RenderTreeFrame[parameters.Count + 1];
|
||||||
frames[0] = RenderTreeFrame.Element(0, GeneratedParameterCollectionElementName)
|
frames[0] = RenderTreeFrame.Element(0, GeneratedParameterViewElementName)
|
||||||
.WithElementSubtreeLength(frames.Length);
|
.WithElementSubtreeLength(frames.Length);
|
||||||
|
|
||||||
var i = 0;
|
var i = 0;
|
||||||
|
|
@ -215,7 +215,153 @@ namespace Microsoft.AspNetCore.Components
|
||||||
frames[++i] = RenderTreeFrame.Attribute(i, kvp.Key, kvp.Value);
|
frames[++i] = RenderTreeFrame.Attribute(i, kvp.Key, kvp.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ParameterCollection(frames, 0);
|
return new ParameterView(frames, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// For each parameter property on <paramref name="target"/>, updates its value to
|
||||||
|
/// match the corresponding entry in the <see cref="ParameterView"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="target">An object that has a public writable property matching each parameter's name and type.</param>
|
||||||
|
public void SetParameterProperties(object target)
|
||||||
|
{
|
||||||
|
if (target is null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(target));
|
||||||
|
}
|
||||||
|
|
||||||
|
ComponentProperties.SetProperties(this, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// An enumerator that iterates through a <see cref="ParameterView"/>.
|
||||||
|
/// </summary>
|
||||||
|
|
||||||
|
// Note that this intentionally does not implement IEnumerator<>. This is the same pattern as Span<>.Enumerator
|
||||||
|
// it's valid to foreach over a type that doesn't implement IEnumerator<>.
|
||||||
|
public struct Enumerator
|
||||||
|
{
|
||||||
|
private RenderTreeFrameParameterEnumerator _directParamsEnumerator;
|
||||||
|
private CascadingParameterEnumerator _cascadingParameterEnumerator;
|
||||||
|
private bool _isEnumeratingDirectParams;
|
||||||
|
|
||||||
|
internal Enumerator(RenderTreeFrame[] frames, int ownerIndex, IReadOnlyList<CascadingParameterState> cascadingParameters)
|
||||||
|
{
|
||||||
|
_directParamsEnumerator = new RenderTreeFrameParameterEnumerator(frames, ownerIndex);
|
||||||
|
_cascadingParameterEnumerator = new CascadingParameterEnumerator(cascadingParameters);
|
||||||
|
_isEnumeratingDirectParams = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the current value of the enumerator.
|
||||||
|
/// </summary>
|
||||||
|
public ParameterValue Current => _isEnumeratingDirectParams
|
||||||
|
? _directParamsEnumerator.Current
|
||||||
|
: _cascadingParameterEnumerator.Current;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Instructs the enumerator to move to the next value in the sequence.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A flag to indicate whether or not there is a next value.</returns>
|
||||||
|
public bool MoveNext()
|
||||||
|
{
|
||||||
|
if (_isEnumeratingDirectParams)
|
||||||
|
{
|
||||||
|
if (_directParamsEnumerator.MoveNext())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_isEnumeratingDirectParams = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return _cascadingParameterEnumerator.MoveNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private struct RenderTreeFrameParameterEnumerator
|
||||||
|
{
|
||||||
|
private readonly RenderTreeFrame[] _frames;
|
||||||
|
private readonly int _ownerIndex;
|
||||||
|
private readonly int _ownerDescendantsEndIndexExcl;
|
||||||
|
private int _currentIndex;
|
||||||
|
private ParameterValue _current;
|
||||||
|
|
||||||
|
internal RenderTreeFrameParameterEnumerator(RenderTreeFrame[] frames, int ownerIndex)
|
||||||
|
{
|
||||||
|
_frames = frames;
|
||||||
|
_ownerIndex = ownerIndex;
|
||||||
|
_ownerDescendantsEndIndexExcl = ownerIndex + _frames[ownerIndex].ElementSubtreeLength;
|
||||||
|
_currentIndex = ownerIndex;
|
||||||
|
_current = default;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ParameterValue Current => _current;
|
||||||
|
|
||||||
|
public bool MoveNext()
|
||||||
|
{
|
||||||
|
// Stop iteration if you get to the end of the owner's descendants...
|
||||||
|
var nextIndex = _currentIndex + 1;
|
||||||
|
if (nextIndex == _ownerDescendantsEndIndexExcl)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ... or if you get to its first non-attribute descendant (because attributes
|
||||||
|
// are always before any other type of descendant)
|
||||||
|
if (_frames[nextIndex].FrameType != RenderTreeFrameType.Attribute)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_currentIndex = nextIndex;
|
||||||
|
|
||||||
|
ref var frame = ref _frames[_currentIndex];
|
||||||
|
_current = new ParameterValue(frame.AttributeName, frame.AttributeValue, false);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private struct CascadingParameterEnumerator
|
||||||
|
{
|
||||||
|
private readonly IReadOnlyList<CascadingParameterState> _cascadingParameters;
|
||||||
|
private int _currentIndex;
|
||||||
|
private ParameterValue _current;
|
||||||
|
|
||||||
|
public CascadingParameterEnumerator(IReadOnlyList<CascadingParameterState> cascadingParameters)
|
||||||
|
{
|
||||||
|
_cascadingParameters = cascadingParameters;
|
||||||
|
_currentIndex = -1;
|
||||||
|
_current = default;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ParameterValue Current => _current;
|
||||||
|
|
||||||
|
public bool MoveNext()
|
||||||
|
{
|
||||||
|
// Bail out early if there are no cascading parameters
|
||||||
|
if (_cascadingParameters == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var nextIndex = _currentIndex + 1;
|
||||||
|
if (nextIndex < _cascadingParameters.Count)
|
||||||
|
{
|
||||||
|
_currentIndex = nextIndex;
|
||||||
|
|
||||||
|
var state = _cascadingParameters[_currentIndex];
|
||||||
|
_current = new ParameterValue(state.LocalValueName, state.ValueSupplier.CurrentValue, true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -7,29 +7,17 @@ using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Microsoft.AspNetCore.Components.Reflection;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Components
|
namespace Microsoft.AspNetCore.Components.Reflection
|
||||||
{
|
{
|
||||||
/// <summary>
|
internal static class ComponentProperties
|
||||||
/// Extension methods for the <see cref="ParameterCollection"/> type.
|
|
||||||
/// </summary>
|
|
||||||
public static class ParameterCollectionExtensions
|
|
||||||
{
|
{
|
||||||
private const BindingFlags _bindablePropertyFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.IgnoreCase;
|
private const BindingFlags _bindablePropertyFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.IgnoreCase;
|
||||||
|
|
||||||
private readonly static ConcurrentDictionary<Type, WritersForType> _cachedWritersByType
|
private readonly static ConcurrentDictionary<Type, WritersForType> _cachedWritersByType
|
||||||
= new ConcurrentDictionary<Type, WritersForType>();
|
= new ConcurrentDictionary<Type, WritersForType>();
|
||||||
|
|
||||||
/// <summary>
|
public static void SetProperties(in ParameterView parameters, object target)
|
||||||
/// For each parameter property on <paramref name="target"/>, updates its value to
|
|
||||||
/// match the corresponding entry in the <see cref="ParameterCollection"/>.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="parameterCollection">The <see cref="ParameterCollection"/>.</param>
|
|
||||||
/// <param name="target">An object that has a public writable property matching each parameter's name and type.</param>
|
|
||||||
public static void SetParameterProperties(
|
|
||||||
in this ParameterCollection parameterCollection,
|
|
||||||
object target)
|
|
||||||
{
|
{
|
||||||
if (target == null)
|
if (target == null)
|
||||||
{
|
{
|
||||||
|
|
@ -47,7 +35,7 @@ namespace Microsoft.AspNetCore.Components
|
||||||
if (writers.CaptureUnmatchedValuesWriter == null)
|
if (writers.CaptureUnmatchedValuesWriter == null)
|
||||||
{
|
{
|
||||||
// Logic for components without a CaptureUnmatchedValues parameter
|
// Logic for components without a CaptureUnmatchedValues parameter
|
||||||
foreach (var parameter in parameterCollection)
|
foreach (var parameter in parameters)
|
||||||
{
|
{
|
||||||
var parameterName = parameter.Name;
|
var parameterName = parameter.Name;
|
||||||
if (!writers.WritersByName.TryGetValue(parameterName, out var writer))
|
if (!writers.WritersByName.TryGetValue(parameterName, out var writer))
|
||||||
|
|
@ -65,7 +53,7 @@ namespace Microsoft.AspNetCore.Components
|
||||||
// Logic with components with a CaptureUnmatchedValues parameter
|
// Logic with components with a CaptureUnmatchedValues parameter
|
||||||
var isCaptureUnmatchedValuesParameterSetExplicitly = false;
|
var isCaptureUnmatchedValuesParameterSetExplicitly = false;
|
||||||
Dictionary<string, object> unmatched = null;
|
Dictionary<string, object> unmatched = null;
|
||||||
foreach (var parameter in parameterCollection)
|
foreach (var parameter in parameters)
|
||||||
{
|
{
|
||||||
var parameterName = parameter.Name;
|
var parameterName = parameter.Name;
|
||||||
if (string.Equals(parameterName, writers.CaptureUnmatchedValuesPropertyName, StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(parameterName, writers.CaptureUnmatchedValuesPropertyName, StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
@ -520,8 +520,8 @@ namespace Microsoft.AspNetCore.Components.RenderTree
|
||||||
// comparisons it wants with the old values. Later we could choose to pass the
|
// comparisons it wants with the old values. Later we could choose to pass the
|
||||||
// old parameter values if we wanted. By default, components always rerender
|
// old parameter values if we wanted. By default, components always rerender
|
||||||
// after any SetParameters call, which is safe but now always optimal for perf.
|
// after any SetParameters call, which is safe but now always optimal for perf.
|
||||||
var oldParameters = new ParameterCollection(oldTree, oldComponentIndex);
|
var oldParameters = new ParameterView(oldTree, oldComponentIndex);
|
||||||
var newParameters = new ParameterCollection(newTree, newComponentIndex);
|
var newParameters = new ParameterView(newTree, newComponentIndex);
|
||||||
if (!newParameters.DefinitelyEquals(oldParameters))
|
if (!newParameters.DefinitelyEquals(oldParameters))
|
||||||
{
|
{
|
||||||
componentState.SetDirectParameters(newParameters);
|
componentState.SetDirectParameters(newParameters);
|
||||||
|
|
@ -894,7 +894,7 @@ namespace Microsoft.AspNetCore.Components.RenderTree
|
||||||
var childComponentState = frame.ComponentState;
|
var childComponentState = frame.ComponentState;
|
||||||
|
|
||||||
// Set initial parameters
|
// Set initial parameters
|
||||||
var initialParameters = new ParameterCollection(frames, frameIndex);
|
var initialParameters = new ParameterView(frames, frameIndex);
|
||||||
childComponentState.SetDirectParameters(initialParameters);
|
childComponentState.SetDirectParameters(initialParameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ namespace Microsoft.AspNetCore.Components.Rendering
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetDirectParameters(ParameterCollection parameters)
|
public void SetDirectParameters(ParameterView parameters)
|
||||||
{
|
{
|
||||||
// Note: We should be careful to ensure that the framework never calls
|
// Note: We should be careful to ensure that the framework never calls
|
||||||
// IComponent.SetParameters directly elsewhere. We should only call it
|
// IComponent.SetParameters directly elsewhere. We should only call it
|
||||||
|
|
@ -137,8 +137,8 @@ namespace Microsoft.AspNetCore.Components.Rendering
|
||||||
public void NotifyCascadingValueChanged()
|
public void NotifyCascadingValueChanged()
|
||||||
{
|
{
|
||||||
var directParams = _latestDirectParametersSnapshot != null
|
var directParams = _latestDirectParametersSnapshot != null
|
||||||
? new ParameterCollection(_latestDirectParametersSnapshot.Buffer, 0)
|
? new ParameterView(_latestDirectParametersSnapshot.Buffer, 0)
|
||||||
: ParameterCollection.Empty;
|
: ParameterView.Empty;
|
||||||
var allParams = directParams.WithCascadingParameters(_cascadingParameters);
|
var allParams = directParams.WithCascadingParameters(_cascadingParameters);
|
||||||
var task = Component.SetParametersAsync(allParams);
|
var task = Component.SetParametersAsync(allParams);
|
||||||
_renderer.AddToPendingTasks(task);
|
_renderer.AddToPendingTasks(task);
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.ExceptionServices;
|
using System.Runtime.ExceptionServices;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Components.RenderTree;
|
using Microsoft.AspNetCore.Components.RenderTree;
|
||||||
|
|
@ -49,9 +48,9 @@ namespace Microsoft.AspNetCore.Components.Rendering
|
||||||
/// of the HTML produced by the component.
|
/// of the HTML produced by the component.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="componentType">The type of the <see cref="IComponent"/>.</param>
|
/// <param name="componentType">The type of the <see cref="IComponent"/>.</param>
|
||||||
/// <param name="initialParameters">A <see cref="ParameterCollection"/> with the initial parameters to render the component.</param>
|
/// <param name="initialParameters">A <see cref="ParameterView"/> with the initial parameters to render the component.</param>
|
||||||
/// <returns>A <see cref="Task"/> that on completion returns a sequence of <see cref="string"/> fragments that represent the HTML text of the component.</returns>
|
/// <returns>A <see cref="Task"/> that on completion returns a sequence of <see cref="string"/> fragments that represent the HTML text of the component.</returns>
|
||||||
public async Task<ComponentRenderedText> RenderComponentAsync(Type componentType, ParameterCollection initialParameters)
|
public async Task<ComponentRenderedText> RenderComponentAsync(Type componentType, ParameterView initialParameters)
|
||||||
{
|
{
|
||||||
var (componentId, frames) = await CreateInitialRenderAsync(componentType, initialParameters);
|
var (componentId, frames) = await CreateInitialRenderAsync(componentType, initialParameters);
|
||||||
|
|
||||||
|
|
@ -66,9 +65,9 @@ namespace Microsoft.AspNetCore.Components.Rendering
|
||||||
/// of the HTML produced by the component.
|
/// of the HTML produced by the component.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TComponent">The type of the <see cref="IComponent"/>.</typeparam>
|
/// <typeparam name="TComponent">The type of the <see cref="IComponent"/>.</typeparam>
|
||||||
/// <param name="initialParameters">A <see cref="ParameterCollection"/> with the initial parameters to render the component.</param>
|
/// <param name="initialParameters">A <see cref="ParameterView"/> with the initial parameters to render the component.</param>
|
||||||
/// <returns>A <see cref="Task"/> that on completion returns a sequence of <see cref="string"/> fragments that represent the HTML text of the component.</returns>
|
/// <returns>A <see cref="Task"/> that on completion returns a sequence of <see cref="string"/> fragments that represent the HTML text of the component.</returns>
|
||||||
public Task<ComponentRenderedText> RenderComponentAsync<TComponent>(ParameterCollection initialParameters) where TComponent : IComponent
|
public Task<ComponentRenderedText> RenderComponentAsync<TComponent>(ParameterView initialParameters) where TComponent : IComponent
|
||||||
{
|
{
|
||||||
return RenderComponentAsync(typeof(TComponent), initialParameters);
|
return RenderComponentAsync(typeof(TComponent), initialParameters);
|
||||||
}
|
}
|
||||||
|
|
@ -224,7 +223,7 @@ namespace Microsoft.AspNetCore.Components.Rendering
|
||||||
return position + maxElements;
|
return position + maxElements;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<(int, ArrayRange<RenderTreeFrame>)> CreateInitialRenderAsync(Type componentType, ParameterCollection initialParameters)
|
private async Task<(int, ArrayRange<RenderTreeFrame>)> CreateInitialRenderAsync(Type componentType, ParameterView initialParameters)
|
||||||
{
|
{
|
||||||
var component = InstantiateComponent(componentType);
|
var component = InstantiateComponent(componentType);
|
||||||
var componentId = AssignRootComponentId(component);
|
var componentId = AssignRootComponentId(component);
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,7 @@ namespace Microsoft.AspNetCore.Components.Rendering
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
protected Task RenderRootComponentAsync(int componentId)
|
protected Task RenderRootComponentAsync(int componentId)
|
||||||
{
|
{
|
||||||
return RenderRootComponentAsync(componentId, ParameterCollection.Empty);
|
return RenderRootComponentAsync(componentId, ParameterView.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -120,12 +120,12 @@ namespace Microsoft.AspNetCore.Components.Rendering
|
||||||
/// this more than once.
|
/// this more than once.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="componentId">The ID returned by <see cref="AssignRootComponentId(IComponent)"/>.</param>
|
/// <param name="componentId">The ID returned by <see cref="AssignRootComponentId(IComponent)"/>.</param>
|
||||||
/// <param name="initialParameters">The <see cref="ParameterCollection"/>with the initial parameters to use for rendering.</param>
|
/// <param name="initialParameters">The <see cref="ParameterView"/>with the initial parameters to use for rendering.</param>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Rendering a root component is an asynchronous operation. Clients may choose to not await the returned task to
|
/// Rendering a root component is an asynchronous operation. Clients may choose to not await the returned task to
|
||||||
/// start, but not wait for the entire render to complete.
|
/// start, but not wait for the entire render to complete.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
protected async Task RenderRootComponentAsync(int componentId, ParameterCollection initialParameters)
|
protected async Task RenderRootComponentAsync(int componentId, ParameterView initialParameters)
|
||||||
{
|
{
|
||||||
if (Interlocked.CompareExchange(ref _pendingTasks, new List<Task>(), null) != null)
|
if (Interlocked.CompareExchange(ref _pendingTasks, new List<Task>(), null) != null)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ namespace Microsoft.AspNetCore.Components.Routing
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public Task SetParametersAsync(ParameterCollection parameters)
|
public Task SetParametersAsync(ParameterView parameters)
|
||||||
{
|
{
|
||||||
parameters.SetParameterProperties(this);
|
parameters.SetParameterProperties(this);
|
||||||
Routes = RouteTableFactory.Create(AppAssembly);
|
Routes = RouteTableFactory.Create(AppAssembly);
|
||||||
|
|
|
||||||
|
|
@ -386,7 +386,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
supplierParams.Add("Name", name);
|
supplierParams.Add("Name", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer.Dispatcher.InvokeAsync((Action)(() => supplier.SetParametersAsync(ParameterCollection.FromDictionary(supplierParams))));
|
renderer.Dispatcher.InvokeAsync((Action)(() => supplier.SetParametersAsync(ParameterView.FromDictionary(supplierParams))));
|
||||||
return supplier;
|
return supplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -427,7 +427,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
public void Attach(RenderHandle renderHandle)
|
public void Attach(RenderHandle renderHandle)
|
||||||
=> throw new NotImplementedException();
|
=> throw new NotImplementedException();
|
||||||
|
|
||||||
public Task SetParametersAsync(ParameterCollection parameters)
|
public Task SetParametersAsync(ParameterView parameters)
|
||||||
=> throw new NotImplementedException();
|
=> throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -383,7 +383,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
[CascadingParameter] T CascadingParameter { get; set; }
|
[CascadingParameter] T CascadingParameter { get; set; }
|
||||||
[Parameter] public string RegularParameter { get; set; }
|
[Parameter] public string RegularParameter { get; set; }
|
||||||
|
|
||||||
public override async Task SetParametersAsync(ParameterCollection parameters)
|
public override async Task SetParametersAsync(ParameterView parameters)
|
||||||
{
|
{
|
||||||
NumSetParametersCalls++;
|
NumSetParametersCalls++;
|
||||||
await base.SetParametersAsync(parameters);
|
await base.SetParametersAsync(parameters);
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ namespace Microsoft.AspNetCore.Components
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task SetParametersAsync(ParameterCollection parameters)
|
public Task SetParametersAsync(ParameterView parameters)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
@ -130,7 +130,7 @@ namespace Microsoft.AspNetCore.Components
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task SetParametersAsync(ParameterCollection parameters)
|
public Task SetParametersAsync(ParameterView parameters)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
@ -148,7 +148,7 @@ namespace Microsoft.AspNetCore.Components
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task SetParametersAsync(ParameterCollection parameters)
|
public Task SetParametersAsync(ParameterView parameters)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -197,7 +197,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
public void Attach(RenderHandle renderHandle)
|
public void Attach(RenderHandle renderHandle)
|
||||||
=> throw new NotImplementedException();
|
=> throw new NotImplementedException();
|
||||||
|
|
||||||
public Task SetParametersAsync(ParameterCollection parameters)
|
public Task SetParametersAsync(ParameterView parameters)
|
||||||
=> throw new NotImplementedException();
|
=> throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -667,7 +667,7 @@ namespace Microsoft.AspNetCore.Components
|
||||||
throw new System.NotImplementedException();
|
throw new System.NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task SetParametersAsync(ParameterCollection parameters)
|
public Task SetParametersAsync(ParameterView parameters)
|
||||||
{
|
{
|
||||||
throw new System.NotImplementedException();
|
throw new System.NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -645,7 +645,7 @@ namespace Microsoft.AspNetCore.Components
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task SetParametersAsync(ParameterCollection parameters)
|
public Task SetParametersAsync(ParameterView parameters)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -451,7 +451,7 @@ namespace Microsoft.AspNetCore.Components
|
||||||
|
|
||||||
public void Attach(RenderHandle renderHandle) => throw new NotImplementedException();
|
public void Attach(RenderHandle renderHandle) => throw new NotImplementedException();
|
||||||
|
|
||||||
public Task SetParametersAsync(ParameterCollection parameters) => throw new NotImplementedException();
|
public Task SetParametersAsync(ParameterView parameters) => throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
public void DisplaysComponentInsideLayout()
|
public void DisplaysComponentInsideLayout()
|
||||||
{
|
{
|
||||||
// Arrange/Act
|
// Arrange/Act
|
||||||
_renderer.Dispatcher.InvokeAsync(() => _pageDisplayComponent.SetParametersAsync(ParameterCollection.FromDictionary(new Dictionary<string, object>
|
_renderer.Dispatcher.InvokeAsync(() => _pageDisplayComponent.SetParametersAsync(ParameterView.FromDictionary(new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
{ nameof(PageDisplay.Page), typeof(ComponentWithLayout) }
|
{ nameof(PageDisplay.Page), typeof(ComponentWithLayout) }
|
||||||
})));
|
})));
|
||||||
|
|
@ -84,7 +84,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
public void DisplaysComponentInsideNestedLayout()
|
public void DisplaysComponentInsideNestedLayout()
|
||||||
{
|
{
|
||||||
// Arrange/Act
|
// Arrange/Act
|
||||||
_renderer.Dispatcher.InvokeAsync(() => _pageDisplayComponent.SetParametersAsync(ParameterCollection.FromDictionary(new Dictionary<string, object>
|
_renderer.Dispatcher.InvokeAsync(() => _pageDisplayComponent.SetParametersAsync(ParameterView.FromDictionary(new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
{ nameof(PageDisplay.Page), typeof(ComponentWithNestedLayout) }
|
{ nameof(PageDisplay.Page), typeof(ComponentWithNestedLayout) }
|
||||||
})));
|
})));
|
||||||
|
|
@ -111,13 +111,13 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
public void CanChangeDisplayedPageWithSameLayout()
|
public void CanChangeDisplayedPageWithSameLayout()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
_renderer.Dispatcher.InvokeAsync(() => _pageDisplayComponent.SetParametersAsync(ParameterCollection.FromDictionary(new Dictionary<string, object>
|
_renderer.Dispatcher.InvokeAsync(() => _pageDisplayComponent.SetParametersAsync(ParameterView.FromDictionary(new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
{ nameof(PageDisplay.Page), typeof(ComponentWithLayout) }
|
{ nameof(PageDisplay.Page), typeof(ComponentWithLayout) }
|
||||||
})));
|
})));
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
_renderer.Dispatcher.InvokeAsync(() => _pageDisplayComponent.SetParametersAsync(ParameterCollection.FromDictionary(new Dictionary<string, object>
|
_renderer.Dispatcher.InvokeAsync(() => _pageDisplayComponent.SetParametersAsync(ParameterView.FromDictionary(new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
{ nameof(PageDisplay.Page), typeof(DifferentComponentWithLayout) }
|
{ nameof(PageDisplay.Page), typeof(DifferentComponentWithLayout) }
|
||||||
})));
|
})));
|
||||||
|
|
@ -162,13 +162,13 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
public void CanChangeDisplayedPageWithDifferentLayout()
|
public void CanChangeDisplayedPageWithDifferentLayout()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
_renderer.Dispatcher.InvokeAsync(() => _pageDisplayComponent.SetParametersAsync(ParameterCollection.FromDictionary(new Dictionary<string, object>
|
_renderer.Dispatcher.InvokeAsync(() => _pageDisplayComponent.SetParametersAsync(ParameterView.FromDictionary(new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
{ nameof(PageDisplay.Page), typeof(ComponentWithLayout) }
|
{ nameof(PageDisplay.Page), typeof(ComponentWithLayout) }
|
||||||
})));
|
})));
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
_renderer.Dispatcher.InvokeAsync(() => _pageDisplayComponent.SetParametersAsync(ParameterCollection.FromDictionary(new Dictionary<string, object>
|
_renderer.Dispatcher.InvokeAsync(() => _pageDisplayComponent.SetParametersAsync(ParameterView.FromDictionary(new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
{ nameof(PageDisplay.Page), typeof(ComponentWithNestedLayout) }
|
{ nameof(PageDisplay.Page), typeof(ComponentWithNestedLayout) }
|
||||||
})));
|
})));
|
||||||
|
|
|
||||||
|
|
@ -10,16 +10,16 @@ using Microsoft.AspNetCore.Components.RenderTree;
|
||||||
using Microsoft.AspNetCore.Components.Test.Helpers;
|
using Microsoft.AspNetCore.Components.Test.Helpers;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Components.Test
|
namespace Microsoft.AspNetCore.Components
|
||||||
{
|
{
|
||||||
public class ParameterCollectionAssignmentExtensionsTest
|
public partial class ParameterViewTest
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public void IncomingParameterMatchesAnnotatedPrivateProperty_SetsValue()
|
public void IncomingParameterMatchesAnnotatedPrivateProperty_SetsValue()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var someObject = new object();
|
var someObject = new object();
|
||||||
var parameterCollection = new ParameterCollectionBuilder
|
var parameters = new ParameterViewBuilder
|
||||||
{
|
{
|
||||||
{ nameof(HasInstanceProperties.IntProp), 123 },
|
{ nameof(HasInstanceProperties.IntProp), 123 },
|
||||||
{ nameof(HasInstanceProperties.StringProp), "Hello" },
|
{ nameof(HasInstanceProperties.StringProp), "Hello" },
|
||||||
|
|
@ -28,7 +28,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
var target = new HasInstanceProperties();
|
var target = new HasInstanceProperties();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
parameterCollection.SetParameterProperties(target);
|
parameters.SetParameterProperties(target);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(123, target.IntProp);
|
Assert.Equal(123, target.IntProp);
|
||||||
|
|
@ -40,14 +40,14 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
public void IncomingParameterMatchesDeclaredParameterCaseInsensitively_SetsValue()
|
public void IncomingParameterMatchesDeclaredParameterCaseInsensitively_SetsValue()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var parameterCollection = new ParameterCollectionBuilder
|
var parameters = new ParameterViewBuilder
|
||||||
{
|
{
|
||||||
{ nameof(HasInstanceProperties.IntProp).ToLowerInvariant(), 123 }
|
{ nameof(HasInstanceProperties.IntProp).ToLowerInvariant(), 123 }
|
||||||
}.Build();
|
}.Build();
|
||||||
var target = new HasInstanceProperties();
|
var target = new HasInstanceProperties();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
parameterCollection.SetParameterProperties(target);
|
parameters.SetParameterProperties(target);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(123, target.IntProp);
|
Assert.Equal(123, target.IntProp);
|
||||||
|
|
@ -57,7 +57,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
public void IncomingParameterMatchesInheritedDeclaredParameter_SetsValue()
|
public void IncomingParameterMatchesInheritedDeclaredParameter_SetsValue()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var parameterCollection = new ParameterCollectionBuilder
|
var parameters = new ParameterViewBuilder
|
||||||
{
|
{
|
||||||
{ nameof(HasInheritedProperties.IntProp), 123 },
|
{ nameof(HasInheritedProperties.IntProp), 123 },
|
||||||
{ nameof(HasInheritedProperties.DerivedClassIntProp), 456 },
|
{ nameof(HasInheritedProperties.DerivedClassIntProp), 456 },
|
||||||
|
|
@ -65,7 +65,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
var target = new HasInheritedProperties();
|
var target = new HasInheritedProperties();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
parameterCollection.SetParameterProperties(target);
|
parameters.SetParameterProperties(target);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(123, target.IntProp);
|
Assert.Equal(123, target.IntProp);
|
||||||
|
|
@ -84,10 +84,10 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
ObjectPropCurrentValue = existingObjectValue
|
ObjectPropCurrentValue = existingObjectValue
|
||||||
};
|
};
|
||||||
|
|
||||||
var parameterCollection = new ParameterCollectionBuilder().Build();
|
var parameters = new ParameterViewBuilder().Build();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
parameterCollection.SetParameterProperties(target);
|
parameters.SetParameterProperties(target);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(456, target.IntProp);
|
Assert.Equal(456, target.IntProp);
|
||||||
|
|
@ -100,14 +100,14 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var target = new HasPropertyWithoutParameterAttribute();
|
var target = new HasPropertyWithoutParameterAttribute();
|
||||||
var parameterCollection = new ParameterCollectionBuilder
|
var parameters = new ParameterViewBuilder
|
||||||
{
|
{
|
||||||
{ "AnyOtherKey", 123 },
|
{ "AnyOtherKey", 123 },
|
||||||
}.Build();
|
}.Build();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var ex = Assert.Throws<InvalidOperationException>(
|
var ex = Assert.Throws<InvalidOperationException>(
|
||||||
() => parameterCollection.SetParameterProperties(target));
|
() => parameters.SetParameterProperties(target));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(
|
Assert.Equal(
|
||||||
|
|
@ -121,14 +121,14 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var target = new HasPropertyWithoutParameterAttribute();
|
var target = new HasPropertyWithoutParameterAttribute();
|
||||||
var parameterCollection = new ParameterCollectionBuilder
|
var parameters = new ParameterViewBuilder
|
||||||
{
|
{
|
||||||
{ nameof(HasPropertyWithoutParameterAttribute.IntProp), 123 },
|
{ nameof(HasPropertyWithoutParameterAttribute.IntProp), 123 },
|
||||||
}.Build();
|
}.Build();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var ex = Assert.Throws<InvalidOperationException>(
|
var ex = Assert.Throws<InvalidOperationException>(
|
||||||
() => parameterCollection.SetParameterProperties(target));
|
() => parameters.SetParameterProperties(target));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(default, target.IntProp);
|
Assert.Equal(default, target.IntProp);
|
||||||
|
|
@ -144,13 +144,13 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
// Arrange
|
// Arrange
|
||||||
var target = new HasCaptureUnmatchedValuesProperty();
|
var target = new HasCaptureUnmatchedValuesProperty();
|
||||||
var value = new Dictionary<string, object>();
|
var value = new Dictionary<string, object>();
|
||||||
var parameterCollection = new ParameterCollectionBuilder
|
var parameters = new ParameterViewBuilder
|
||||||
{
|
{
|
||||||
{ nameof(HasCaptureUnmatchedValuesProperty.CaptureUnmatchedValues), value },
|
{ nameof(HasCaptureUnmatchedValuesProperty.CaptureUnmatchedValues), value },
|
||||||
}.Build();
|
}.Build();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
parameterCollection.SetParameterProperties(target);
|
parameters.SetParameterProperties(target);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Same(value, target.CaptureUnmatchedValues);
|
Assert.Same(value, target.CaptureUnmatchedValues);
|
||||||
|
|
@ -161,7 +161,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var target = new HasCaptureUnmatchedValuesProperty();
|
var target = new HasCaptureUnmatchedValuesProperty();
|
||||||
var parameterCollection = new ParameterCollectionBuilder
|
var parameters = new ParameterViewBuilder
|
||||||
{
|
{
|
||||||
{ nameof(HasCaptureUnmatchedValuesProperty.StringProp), "hi" },
|
{ nameof(HasCaptureUnmatchedValuesProperty.StringProp), "hi" },
|
||||||
{ "test1", 123 },
|
{ "test1", 123 },
|
||||||
|
|
@ -169,7 +169,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
}.Build();
|
}.Build();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
parameterCollection.SetParameterProperties(target);
|
parameters.SetParameterProperties(target);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal("hi", target.StringProp);
|
Assert.Equal("hi", target.StringProp);
|
||||||
|
|
@ -192,7 +192,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var target = new HasCaptureUnmatchedValuesProperty();
|
var target = new HasCaptureUnmatchedValuesProperty();
|
||||||
var parameterCollection = new ParameterCollectionBuilder
|
var parameters = new ParameterViewBuilder
|
||||||
{
|
{
|
||||||
{ nameof(HasCaptureUnmatchedValuesProperty.CaptureUnmatchedValues), new Dictionary<string, object>() },
|
{ nameof(HasCaptureUnmatchedValuesProperty.CaptureUnmatchedValues), new Dictionary<string, object>() },
|
||||||
{ "test1", 123 },
|
{ "test1", 123 },
|
||||||
|
|
@ -200,7 +200,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
}.Build();
|
}.Build();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var ex = Assert.Throws<InvalidOperationException>(() => parameterCollection.SetParameterProperties(target));
|
var ex = Assert.Throws<InvalidOperationException>(() => parameters.SetParameterProperties(target));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(
|
Assert.Equal(
|
||||||
|
|
@ -216,7 +216,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var target = new HasCaptureUnmatchedValuesProperty();
|
var target = new HasCaptureUnmatchedValuesProperty();
|
||||||
var parameterCollection = new ParameterCollectionBuilder
|
var parameters = new ParameterViewBuilder
|
||||||
{
|
{
|
||||||
{ "test2", 456 },
|
{ "test2", 456 },
|
||||||
{ "test1", 123 },
|
{ "test1", 123 },
|
||||||
|
|
@ -224,7 +224,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
}.Build();
|
}.Build();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var ex = Assert.Throws<InvalidOperationException>(() => parameterCollection.SetParameterProperties(target));
|
var ex = Assert.Throws<InvalidOperationException>(() => parameters.SetParameterProperties(target));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(
|
Assert.Equal(
|
||||||
|
|
@ -240,10 +240,10 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var target = new HasDupliateCaptureUnmatchedValuesProperty();
|
var target = new HasDupliateCaptureUnmatchedValuesProperty();
|
||||||
var parameterCollection = new ParameterCollectionBuilder().Build();
|
var parameters = new ParameterViewBuilder().Build();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var ex = Assert.Throws<InvalidOperationException>(() => parameterCollection.SetParameterProperties(target));
|
var ex = Assert.Throws<InvalidOperationException>(() => parameters.SetParameterProperties(target));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(
|
Assert.Equal(
|
||||||
|
|
@ -261,10 +261,10 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var target = new HasWrongTypeCaptureUnmatchedValuesProperty();
|
var target = new HasWrongTypeCaptureUnmatchedValuesProperty();
|
||||||
var parameterCollection = new ParameterCollectionBuilder().Build();
|
var parameters = new ParameterViewBuilder().Build();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var ex = Assert.Throws<InvalidOperationException>(() => parameterCollection.SetParameterProperties(target));
|
var ex = Assert.Throws<InvalidOperationException>(() => parameters.SetParameterProperties(target));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(
|
Assert.Equal(
|
||||||
|
|
@ -279,7 +279,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var someObject = new object();
|
var someObject = new object();
|
||||||
var parameterCollection = new ParameterCollectionBuilder
|
var parameters = new ParameterViewBuilder
|
||||||
{
|
{
|
||||||
{ nameof(HasInstanceProperties.IntProp), "string value" },
|
{ nameof(HasInstanceProperties.IntProp), "string value" },
|
||||||
}.Build();
|
}.Build();
|
||||||
|
|
@ -287,7 +287,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var ex = Assert.Throws<InvalidOperationException>(
|
var ex = Assert.Throws<InvalidOperationException>(
|
||||||
() => parameterCollection.SetParameterProperties(target));
|
() => parameters.SetParameterProperties(target));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(
|
Assert.Equal(
|
||||||
|
|
@ -301,14 +301,14 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var target = new HasPropertyWhoseSetterThrows();
|
var target = new HasPropertyWhoseSetterThrows();
|
||||||
var parameterCollection = new ParameterCollectionBuilder
|
var parameters = new ParameterViewBuilder
|
||||||
{
|
{
|
||||||
{ nameof(HasPropertyWhoseSetterThrows.StringProp), "anything" },
|
{ nameof(HasPropertyWhoseSetterThrows.StringProp), "anything" },
|
||||||
}.Build();
|
}.Build();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var ex = Assert.Throws<InvalidOperationException>(
|
var ex = Assert.Throws<InvalidOperationException>(
|
||||||
() => parameterCollection.SetParameterProperties(target));
|
() => parameters.SetParameterProperties(target));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(
|
Assert.Equal(
|
||||||
|
|
@ -321,12 +321,12 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
public void DeclaredParametersVaryOnlyByCase_Throws()
|
public void DeclaredParametersVaryOnlyByCase_Throws()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var parameterCollection = new ParameterCollectionBuilder().Build();
|
var parameters = new ParameterViewBuilder().Build();
|
||||||
var target = new HasParametersVaryingOnlyByCase();
|
var target = new HasParametersVaryingOnlyByCase();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var ex = Assert.Throws<InvalidOperationException>(() =>
|
var ex = Assert.Throws<InvalidOperationException>(() =>
|
||||||
parameterCollection.SetParameterProperties(target));
|
parameters.SetParameterProperties(target));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(
|
Assert.Equal(
|
||||||
|
|
@ -344,12 +344,12 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
// base class can legitimately depend on it for correct functioning.
|
// base class can legitimately depend on it for correct functioning.
|
||||||
|
|
||||||
// Arrange
|
// Arrange
|
||||||
var parameterCollection = new ParameterCollectionBuilder().Build();
|
var parameters = new ParameterViewBuilder().Build();
|
||||||
var target = new HasParameterClashingWithInherited();
|
var target = new HasParameterClashingWithInherited();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var ex = Assert.Throws<InvalidOperationException>(() =>
|
var ex = Assert.Throws<InvalidOperationException>(() =>
|
||||||
parameterCollection.SetParameterProperties(target));
|
parameters.SetParameterProperties(target));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(
|
Assert.Equal(
|
||||||
|
|
@ -362,7 +362,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
public void SupplyingNullWritesDefaultForType()
|
public void SupplyingNullWritesDefaultForType()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var parameterCollection = new ParameterCollectionBuilder
|
var parameters = new ParameterViewBuilder
|
||||||
{
|
{
|
||||||
{ nameof(HasInstanceProperties.IntProp), null },
|
{ nameof(HasInstanceProperties.IntProp), null },
|
||||||
{ nameof(HasInstanceProperties.StringProp), null },
|
{ nameof(HasInstanceProperties.StringProp), null },
|
||||||
|
|
@ -370,7 +370,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
var target = new HasInstanceProperties { IntProp = 123, StringProp = "Hello" };
|
var target = new HasInstanceProperties { IntProp = 123, StringProp = "Hello" };
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
parameterCollection.SetParameterProperties(target);
|
parameters.SetParameterProperties(target);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(0, target.IntProp);
|
Assert.Equal(0, target.IntProp);
|
||||||
|
|
@ -446,7 +446,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
[Parameter(CaptureUnmatchedValues = true)] public KeyValuePair<string, object>[] CaptureUnmatchedValuesProp { get; set; }
|
[Parameter(CaptureUnmatchedValues = true)] public KeyValuePair<string, object>[] CaptureUnmatchedValuesProp { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
class ParameterCollectionBuilder : IEnumerable
|
class ParameterViewBuilder : IEnumerable
|
||||||
{
|
{
|
||||||
private readonly List<(string Name, object Value)> _keyValuePairs
|
private readonly List<(string Name, object Value)> _keyValuePairs
|
||||||
= new List<(string, object)>();
|
= new List<(string, object)>();
|
||||||
|
|
@ -457,7 +457,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
public IEnumerator GetEnumerator()
|
public IEnumerator GetEnumerator()
|
||||||
=> throw new NotImplementedException();
|
=> throw new NotImplementedException();
|
||||||
|
|
||||||
public ParameterCollection Build()
|
public ParameterView Build()
|
||||||
{
|
{
|
||||||
var builder = new RenderTreeBuilder();
|
var builder = new RenderTreeBuilder();
|
||||||
builder.OpenComponent<FakeComponent>(0);
|
builder.OpenComponent<FakeComponent>(0);
|
||||||
|
|
@ -466,17 +466,8 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
builder.AddAttribute(1, kvp.Name, kvp.Value);
|
builder.AddAttribute(1, kvp.Name, kvp.Value);
|
||||||
}
|
}
|
||||||
builder.CloseComponent();
|
builder.CloseComponent();
|
||||||
return new ParameterCollection(builder.GetFrames().Array, ownerIndex: 0);
|
return new ParameterView(builder.GetFrames().Array, ownerIndex: 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class FakeComponent : IComponent
|
|
||||||
{
|
|
||||||
public void Attach(RenderHandle renderHandle)
|
|
||||||
=> throw new NotImplementedException();
|
|
||||||
|
|
||||||
public Task SetParametersAsync(ParameterCollection parameters)
|
|
||||||
=> throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -8,9 +8,9 @@ using Microsoft.AspNetCore.Components.Rendering;
|
||||||
using Microsoft.AspNetCore.Components.RenderTree;
|
using Microsoft.AspNetCore.Components.RenderTree;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Components.Test
|
namespace Microsoft.AspNetCore.Components
|
||||||
{
|
{
|
||||||
public class ParameterCollectionTest
|
public partial class ParameterViewTest
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public void CanInitializeUsingComponentWithNoDescendants()
|
public void CanInitializeUsingComponentWithNoDescendants()
|
||||||
|
|
@ -20,10 +20,10 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
{
|
{
|
||||||
RenderTreeFrame.ChildComponent(0, typeof(FakeComponent)).WithComponentSubtreeLength(1)
|
RenderTreeFrame.ChildComponent(0, typeof(FakeComponent)).WithComponentSubtreeLength(1)
|
||||||
};
|
};
|
||||||
var parameterCollection = new ParameterCollection(frames, 0);
|
var parameters = new ParameterView(frames, 0);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Empty(ToEnumerable(parameterCollection));
|
Assert.Empty(ToEnumerable(parameters));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -34,10 +34,10 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
{
|
{
|
||||||
RenderTreeFrame.Element(0, "some element").WithElementSubtreeLength(1)
|
RenderTreeFrame.Element(0, "some element").WithElementSubtreeLength(1)
|
||||||
};
|
};
|
||||||
var parameterCollection = new ParameterCollection(frames, 0);
|
var parameters = new ParameterView(frames, 0);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Empty(ToEnumerable(parameterCollection));
|
Assert.Empty(ToEnumerable(parameters));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -52,14 +52,14 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
RenderTreeFrame.Attribute(1, "attribute 1", attribute1Value),
|
RenderTreeFrame.Attribute(1, "attribute 1", attribute1Value),
|
||||||
RenderTreeFrame.Attribute(2, "attribute 2", attribute2Value),
|
RenderTreeFrame.Attribute(2, "attribute 2", attribute2Value),
|
||||||
// Although RenderTreeBuilder doesn't let you add orphaned attributes like this,
|
// Although RenderTreeBuilder doesn't let you add orphaned attributes like this,
|
||||||
// still want to verify that ParameterCollection doesn't attempt to read past the
|
// still want to verify that parameters doesn't attempt to read past the
|
||||||
// end of the owner's descendants
|
// end of the owner's descendants
|
||||||
RenderTreeFrame.Attribute(3, "orphaned attribute", "value")
|
RenderTreeFrame.Attribute(3, "orphaned attribute", "value")
|
||||||
};
|
};
|
||||||
var parameterCollection = new ParameterCollection(frames, 0);
|
var parameters = new ParameterView(frames, 0);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Collection(ToEnumerable(parameterCollection),
|
Assert.Collection(ToEnumerable(parameters),
|
||||||
AssertParameter("attribute 1", attribute1Value, false),
|
AssertParameter("attribute 1", attribute1Value, false),
|
||||||
AssertParameter("attribute 2", attribute2Value, false));
|
AssertParameter("attribute 2", attribute2Value, false));
|
||||||
}
|
}
|
||||||
|
|
@ -78,10 +78,10 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
RenderTreeFrame.Element(3, "child element").WithElementSubtreeLength(2),
|
RenderTreeFrame.Element(3, "child element").WithElementSubtreeLength(2),
|
||||||
RenderTreeFrame.Attribute(4, "child attribute", "some value")
|
RenderTreeFrame.Attribute(4, "child attribute", "some value")
|
||||||
};
|
};
|
||||||
var parameterCollection = new ParameterCollection(frames, 0);
|
var parameters = new ParameterView(frames, 0);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Collection(ToEnumerable(parameterCollection),
|
Assert.Collection(ToEnumerable(parameters),
|
||||||
AssertParameter("attribute 1", attribute1Value, false),
|
AssertParameter("attribute 1", attribute1Value, false),
|
||||||
AssertParameter("attribute 2", attribute2Value, false));
|
AssertParameter("attribute 2", attribute2Value, false));
|
||||||
}
|
}
|
||||||
|
|
@ -93,7 +93,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
var attribute1Value = new object();
|
var attribute1Value = new object();
|
||||||
var attribute2Value = new object();
|
var attribute2Value = new object();
|
||||||
var attribute3Value = new object();
|
var attribute3Value = new object();
|
||||||
var parameterCollection = new ParameterCollection(new[]
|
var parameters = new ParameterView(new[]
|
||||||
{
|
{
|
||||||
RenderTreeFrame.Element(0, "some element").WithElementSubtreeLength(2),
|
RenderTreeFrame.Element(0, "some element").WithElementSubtreeLength(2),
|
||||||
RenderTreeFrame.Attribute(1, "attribute 1", attribute1Value)
|
RenderTreeFrame.Attribute(1, "attribute 1", attribute1Value)
|
||||||
|
|
@ -104,7 +104,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
});
|
});
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Collection(ToEnumerable(parameterCollection),
|
Assert.Collection(ToEnumerable(parameters),
|
||||||
AssertParameter("attribute 1", attribute1Value, false),
|
AssertParameter("attribute 1", attribute1Value, false),
|
||||||
AssertParameter("attribute 2", attribute2Value, true),
|
AssertParameter("attribute 2", attribute2Value, true),
|
||||||
AssertParameter("attribute 3", attribute3Value, true));
|
AssertParameter("attribute 3", attribute3Value, true));
|
||||||
|
|
@ -114,14 +114,14 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
public void CanTryGetNonExistingValue()
|
public void CanTryGetNonExistingValue()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var parameterCollection = new ParameterCollection(new[]
|
var parameters = new ParameterView(new[]
|
||||||
{
|
{
|
||||||
RenderTreeFrame.Element(0, "some element").WithElementSubtreeLength(2),
|
RenderTreeFrame.Element(0, "some element").WithElementSubtreeLength(2),
|
||||||
RenderTreeFrame.Attribute(1, "some other entry", new object())
|
RenderTreeFrame.Attribute(1, "some other entry", new object())
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var didFind = parameterCollection.TryGetValue<string>("nonexisting entry", out var value);
|
var didFind = parameters.TryGetValue<string>("nonexisting entry", out var value);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.False(didFind);
|
Assert.False(didFind);
|
||||||
|
|
@ -132,14 +132,14 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
public void CanTryGetExistingValueWithCorrectType()
|
public void CanTryGetExistingValueWithCorrectType()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var parameterCollection = new ParameterCollection(new[]
|
var parameters = new ParameterView(new[]
|
||||||
{
|
{
|
||||||
RenderTreeFrame.Element(0, "some element").WithElementSubtreeLength(2),
|
RenderTreeFrame.Element(0, "some element").WithElementSubtreeLength(2),
|
||||||
RenderTreeFrame.Attribute(1, "my entry", "hello")
|
RenderTreeFrame.Attribute(1, "my entry", "hello")
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var didFind = parameterCollection.TryGetValue<string>("my entry", out var value);
|
var didFind = parameters.TryGetValue<string>("my entry", out var value);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.True(didFind);
|
Assert.True(didFind);
|
||||||
|
|
@ -151,7 +151,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var myEntryValue = new object();
|
var myEntryValue = new object();
|
||||||
var parameterCollection = new ParameterCollection(new[]
|
var parameters = new ParameterView(new[]
|
||||||
{
|
{
|
||||||
RenderTreeFrame.Element(0, "some element").WithElementSubtreeLength(2),
|
RenderTreeFrame.Element(0, "some element").WithElementSubtreeLength(2),
|
||||||
RenderTreeFrame.Attribute(1, "my entry", myEntryValue),
|
RenderTreeFrame.Attribute(1, "my entry", myEntryValue),
|
||||||
|
|
@ -159,7 +159,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = parameterCollection.GetValueOrDefault<object>("my entry");
|
var result = parameters.GetValueOrDefault<object>("my entry");
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Same(myEntryValue, result);
|
Assert.Same(myEntryValue, result);
|
||||||
|
|
@ -170,7 +170,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var myEntryValue = new object();
|
var myEntryValue = new object();
|
||||||
var parameterCollection = new ParameterCollection(new[]
|
var parameters = new ParameterView(new[]
|
||||||
{
|
{
|
||||||
RenderTreeFrame.Element(0, "some element").WithElementSubtreeLength(3),
|
RenderTreeFrame.Element(0, "some element").WithElementSubtreeLength(3),
|
||||||
RenderTreeFrame.Attribute(1, "my entry", myEntryValue),
|
RenderTreeFrame.Attribute(1, "my entry", myEntryValue),
|
||||||
|
|
@ -178,7 +178,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = parameterCollection.GetValueOrDefault<object>("my entry");
|
var result = parameters.GetValueOrDefault<object>("my entry");
|
||||||
|
|
||||||
// Assert: Picks first match
|
// Assert: Picks first match
|
||||||
Assert.Same(myEntryValue, result);
|
Assert.Same(myEntryValue, result);
|
||||||
|
|
@ -188,7 +188,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
public void CanGetValueOrDefault_WithNonExistingValue()
|
public void CanGetValueOrDefault_WithNonExistingValue()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var parameterCollection = new ParameterCollection(new[]
|
var parameters = new ParameterView(new[]
|
||||||
{
|
{
|
||||||
RenderTreeFrame.Element(0, "some element").WithElementSubtreeLength(2),
|
RenderTreeFrame.Element(0, "some element").WithElementSubtreeLength(2),
|
||||||
RenderTreeFrame.Attribute(1, "some other entry", new object())
|
RenderTreeFrame.Attribute(1, "some other entry", new object())
|
||||||
|
|
@ -198,7 +198,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
});
|
});
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = parameterCollection.GetValueOrDefault<DateTime>("nonexisting entry");
|
var result = parameters.GetValueOrDefault<DateTime>("nonexisting entry");
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(default, result);
|
Assert.Equal(default, result);
|
||||||
|
|
@ -209,14 +209,14 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var explicitDefaultValue = new DateTime(2018, 3, 20);
|
var explicitDefaultValue = new DateTime(2018, 3, 20);
|
||||||
var parameterCollection = new ParameterCollection(new[]
|
var parameters = new ParameterView(new[]
|
||||||
{
|
{
|
||||||
RenderTreeFrame.Element(0, "some element").WithElementSubtreeLength(2),
|
RenderTreeFrame.Element(0, "some element").WithElementSubtreeLength(2),
|
||||||
RenderTreeFrame.Attribute(1, "some other entry", new object())
|
RenderTreeFrame.Attribute(1, "some other entry", new object())
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = parameterCollection.GetValueOrDefault("nonexisting entry", explicitDefaultValue);
|
var result = parameters.GetValueOrDefault("nonexisting entry", explicitDefaultValue);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(explicitDefaultValue, result);
|
Assert.Equal(explicitDefaultValue, result);
|
||||||
|
|
@ -226,7 +226,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
public void ThrowsIfTryGetExistingValueWithIncorrectType()
|
public void ThrowsIfTryGetExistingValueWithIncorrectType()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var parameterCollection = new ParameterCollection(new[]
|
var parameters = new ParameterView(new[]
|
||||||
{
|
{
|
||||||
RenderTreeFrame.Element(0, "some element").WithElementSubtreeLength(2),
|
RenderTreeFrame.Element(0, "some element").WithElementSubtreeLength(2),
|
||||||
RenderTreeFrame.Attribute(1, "my entry", "hello")
|
RenderTreeFrame.Attribute(1, "my entry", "hello")
|
||||||
|
|
@ -235,7 +235,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
// Act/Assert
|
// Act/Assert
|
||||||
Assert.Throws<InvalidCastException>(() =>
|
Assert.Throws<InvalidCastException>(() =>
|
||||||
{
|
{
|
||||||
parameterCollection.TryGetValue<bool>("my entry", out var value);
|
parameters.TryGetValue<bool>("my entry", out var value);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -246,7 +246,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
var dictionary = new Dictionary<string, object>();
|
var dictionary = new Dictionary<string, object>();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var collection = ParameterCollection.FromDictionary(dictionary);
|
var collection = ParameterView.FromDictionary(dictionary);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Empty(collection.ToDictionary());
|
Assert.Empty(collection.ToDictionary());
|
||||||
|
|
@ -263,7 +263,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var collection = ParameterCollection.FromDictionary(dictionary);
|
var collection = ParameterView.FromDictionary(dictionary);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(dictionary, collection.ToDictionary());
|
Assert.Equal(dictionary, collection.ToDictionary());
|
||||||
|
|
@ -275,7 +275,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var entry2Value = new object();
|
var entry2Value = new object();
|
||||||
var parameterCollection = new ParameterCollection(new[]
|
var parameters = new ParameterView(new[]
|
||||||
{
|
{
|
||||||
RenderTreeFrame.Element(0, "some element").WithElementSubtreeLength(3),
|
RenderTreeFrame.Element(0, "some element").WithElementSubtreeLength(3),
|
||||||
RenderTreeFrame.Attribute(0, "entry 1", "value 1"),
|
RenderTreeFrame.Attribute(0, "entry 1", "value 1"),
|
||||||
|
|
@ -283,7 +283,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
IReadOnlyDictionary<string, object> dict = parameterCollection.ToDictionary();
|
IReadOnlyDictionary<string, object> dict = parameters.ToDictionary();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Collection(dict,
|
Assert.Collection(dict,
|
||||||
|
|
@ -304,7 +304,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var myEntryValue = new object();
|
var myEntryValue = new object();
|
||||||
var parameterCollection = new ParameterCollection(new[]
|
var parameters = new ParameterView(new[]
|
||||||
{
|
{
|
||||||
RenderTreeFrame.Element(0, "some element").WithElementSubtreeLength(2),
|
RenderTreeFrame.Element(0, "some element").WithElementSubtreeLength(2),
|
||||||
RenderTreeFrame.Attribute(1, "unrelated value", new object())
|
RenderTreeFrame.Attribute(1, "unrelated value", new object())
|
||||||
|
|
@ -316,13 +316,13 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
});
|
});
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = parameterCollection.GetValueOrDefault<object>("my entry");
|
var result = parameters.GetValueOrDefault<object>("my entry");
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Same(myEntryValue, result);
|
Assert.Same(myEntryValue, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Action<Parameter> AssertParameter(string expectedName, object expectedValue, bool expectedIsCascading)
|
private Action<ParameterValue> AssertParameter(string expectedName, object expectedValue, bool expectedIsCascading)
|
||||||
{
|
{
|
||||||
return parameter =>
|
return parameter =>
|
||||||
{
|
{
|
||||||
|
|
@ -332,9 +332,9 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Parameter> ToEnumerable(ParameterCollection parameterCollection)
|
public IEnumerable<ParameterValue> ToEnumerable(ParameterView parameters)
|
||||||
{
|
{
|
||||||
foreach (var item in parameterCollection)
|
foreach (var item in parameters)
|
||||||
{
|
{
|
||||||
yield return item;
|
yield return item;
|
||||||
}
|
}
|
||||||
|
|
@ -345,7 +345,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
public void Attach(RenderHandle renderHandle)
|
public void Attach(RenderHandle renderHandle)
|
||||||
=> throw new NotImplementedException();
|
=> throw new NotImplementedException();
|
||||||
|
|
||||||
public Task SetParametersAsync(ParameterCollection parameters)
|
public Task SetParametersAsync(ParameterView parameters)
|
||||||
=> throw new NotImplementedException();
|
=> throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1803,7 +1803,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
{
|
{
|
||||||
public void Attach(RenderHandle renderHandle) { }
|
public void Attach(RenderHandle renderHandle) { }
|
||||||
|
|
||||||
public Task SetParametersAsync(ParameterCollection parameters)
|
public Task SetParametersAsync(ParameterView parameters)
|
||||||
=> throw new NotImplementedException();
|
=> throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2222,7 +2222,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
public string NonParameterProperty { get; set; }
|
public string NonParameterProperty { get; set; }
|
||||||
|
|
||||||
public void Attach(RenderHandle renderHandle) { }
|
public void Attach(RenderHandle renderHandle) { }
|
||||||
public Task SetParametersAsync(ParameterCollection parameters)
|
public Task SetParametersAsync(ParameterView parameters)
|
||||||
{
|
{
|
||||||
parameters.SetParameterProperties(this);
|
parameters.SetParameterProperties(this);
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|
@ -2235,7 +2235,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task SetParametersAsync(ParameterCollection parameters) => Task.CompletedTask;
|
public Task SetParametersAsync(ParameterView parameters) => Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class CaptureSetParametersComponent : IComponent
|
private class CaptureSetParametersComponent : IComponent
|
||||||
|
|
@ -2246,7 +2246,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task SetParametersAsync(ParameterCollection parameters)
|
public Task SetParametersAsync(ParameterView parameters)
|
||||||
{
|
{
|
||||||
SetParametersCallCount++;
|
SetParametersCallCount++;
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|
@ -2260,14 +2260,14 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
|
|
||||||
public void Attach(RenderHandle renderHandle) { }
|
public void Attach(RenderHandle renderHandle) { }
|
||||||
|
|
||||||
public Task SetParametersAsync(ParameterCollection parameters) => Task.CompletedTask;
|
public Task SetParametersAsync(ParameterView parameters) => Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class NonDisposableComponent : IComponent
|
private class NonDisposableComponent : IComponent
|
||||||
{
|
{
|
||||||
public void Attach(RenderHandle renderHandle) { }
|
public void Attach(RenderHandle renderHandle) { }
|
||||||
|
|
||||||
public Task SetParametersAsync(ParameterCollection parameters) => Task.CompletedTask;
|
public Task SetParametersAsync(ParameterView parameters) => Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AssertEdit(
|
private static void AssertEdit(
|
||||||
|
|
|
||||||
|
|
@ -239,7 +239,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
// Act/Assert
|
// Act/Assert
|
||||||
var componentId = renderer.AssignRootComponentId(component);
|
var componentId = renderer.AssignRootComponentId(component);
|
||||||
var log = new ConcurrentQueue<(int id, NestedAsyncComponent.EventType @event)>();
|
var log = new ConcurrentQueue<(int id, NestedAsyncComponent.EventType @event)>();
|
||||||
await renderer.Dispatcher.InvokeAsync(() => renderer.RenderRootComponentAsync(componentId, ParameterCollection.FromDictionary(new Dictionary<string, object>
|
await renderer.Dispatcher.InvokeAsync(() => renderer.RenderRootComponentAsync(componentId, ParameterView.FromDictionary(new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
[EventActionsName] = new Dictionary<int, IList<NestedAsyncComponent.ExecutionAction>>
|
[EventActionsName] = new Dictionary<int, IList<NestedAsyncComponent.ExecutionAction>>
|
||||||
{
|
{
|
||||||
|
|
@ -283,7 +283,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
// Act/Assert
|
// Act/Assert
|
||||||
var componentId = renderer.AssignRootComponentId(component);
|
var componentId = renderer.AssignRootComponentId(component);
|
||||||
var log = new ConcurrentQueue<(int id, NestedAsyncComponent.EventType @event)>();
|
var log = new ConcurrentQueue<(int id, NestedAsyncComponent.EventType @event)>();
|
||||||
await renderer.Dispatcher.InvokeAsync(() => renderer.RenderRootComponentAsync(componentId, ParameterCollection.FromDictionary(new Dictionary<string, object>
|
await renderer.Dispatcher.InvokeAsync(() => renderer.RenderRootComponentAsync(componentId, ParameterView.FromDictionary(new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
[EventActionsName] = new Dictionary<int, IList<NestedAsyncComponent.ExecutionAction>>
|
[EventActionsName] = new Dictionary<int, IList<NestedAsyncComponent.ExecutionAction>>
|
||||||
{
|
{
|
||||||
|
|
@ -327,7 +327,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
// Act/Assert
|
// Act/Assert
|
||||||
var componentId = renderer.AssignRootComponentId(component);
|
var componentId = renderer.AssignRootComponentId(component);
|
||||||
var log = new ConcurrentQueue<(int id, NestedAsyncComponent.EventType @event)>();
|
var log = new ConcurrentQueue<(int id, NestedAsyncComponent.EventType @event)>();
|
||||||
await renderer.Dispatcher.InvokeAsync(() => renderer.RenderRootComponentAsync(componentId, ParameterCollection.FromDictionary(new Dictionary<string, object>
|
await renderer.Dispatcher.InvokeAsync(() => renderer.RenderRootComponentAsync(componentId, ParameterView.FromDictionary(new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
[EventActionsName] = new Dictionary<int, IList<NestedAsyncComponent.ExecutionAction>>
|
[EventActionsName] = new Dictionary<int, IList<NestedAsyncComponent.ExecutionAction>>
|
||||||
{
|
{
|
||||||
|
|
@ -371,7 +371,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
// Act/Assert
|
// Act/Assert
|
||||||
var componentId = renderer.AssignRootComponentId(component);
|
var componentId = renderer.AssignRootComponentId(component);
|
||||||
var log = new ConcurrentQueue<(int id, NestedAsyncComponent.EventType @event)>();
|
var log = new ConcurrentQueue<(int id, NestedAsyncComponent.EventType @event)>();
|
||||||
await renderer.Dispatcher.InvokeAsync(() => renderer.RenderRootComponentAsync(componentId, ParameterCollection.FromDictionary(new Dictionary<string, object>
|
await renderer.Dispatcher.InvokeAsync(() => renderer.RenderRootComponentAsync(componentId, ParameterView.FromDictionary(new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
[EventActionsName] = new Dictionary<int, IList<NestedAsyncComponent.ExecutionAction>>
|
[EventActionsName] = new Dictionary<int, IList<NestedAsyncComponent.ExecutionAction>>
|
||||||
{
|
{
|
||||||
|
|
@ -2776,7 +2776,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
|
|
||||||
// Act/Assert
|
// Act/Assert
|
||||||
var componentId = renderer.AssignRootComponentId(component);
|
var componentId = renderer.AssignRootComponentId(component);
|
||||||
var task = renderer.RenderRootComponentAsync(componentId, ParameterCollection.FromDictionary(new Dictionary<string, object>
|
var task = renderer.RenderRootComponentAsync(componentId, ParameterView.FromDictionary(new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
[nameof(NestedAsyncComponent.EventActions)] = new Dictionary<int, IList<NestedAsyncComponent.ExecutionAction>>
|
[nameof(NestedAsyncComponent.EventActions)] = new Dictionary<int, IList<NestedAsyncComponent.ExecutionAction>>
|
||||||
{
|
{
|
||||||
|
|
@ -2809,7 +2809,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
|
|
||||||
// Act/Assert
|
// Act/Assert
|
||||||
var componentId = renderer.AssignRootComponentId(component);
|
var componentId = renderer.AssignRootComponentId(component);
|
||||||
var renderTask = renderer.RenderRootComponentAsync(componentId, ParameterCollection.FromDictionary(new Dictionary<string, object>
|
var renderTask = renderer.RenderRootComponentAsync(componentId, ParameterView.FromDictionary(new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
[nameof(NestedAsyncComponent.EventActions)] = new Dictionary<int, IList<NestedAsyncComponent.ExecutionAction>>
|
[nameof(NestedAsyncComponent.EventActions)] = new Dictionary<int, IList<NestedAsyncComponent.ExecutionAction>>
|
||||||
{
|
{
|
||||||
|
|
@ -2842,7 +2842,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
|
|
||||||
// Act/Assert
|
// Act/Assert
|
||||||
var componentId = renderer.AssignRootComponentId(component);
|
var componentId = renderer.AssignRootComponentId(component);
|
||||||
var renderTask = renderer.RenderRootComponentAsync(componentId, ParameterCollection.FromDictionary(new Dictionary<string, object>
|
var renderTask = renderer.RenderRootComponentAsync(componentId, ParameterView.FromDictionary(new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
[nameof(NestedAsyncComponent.EventActions)] = new Dictionary<int, IList<NestedAsyncComponent.ExecutionAction>>
|
[nameof(NestedAsyncComponent.EventActions)] = new Dictionary<int, IList<NestedAsyncComponent.ExecutionAction>>
|
||||||
{
|
{
|
||||||
|
|
@ -2876,7 +2876,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
|
|
||||||
// Act/Assert
|
// Act/Assert
|
||||||
var componentId = renderer.AssignRootComponentId(component);
|
var componentId = renderer.AssignRootComponentId(component);
|
||||||
var renderTask = renderer.RenderRootComponentAsync(componentId, ParameterCollection.FromDictionary(new Dictionary<string, object>
|
var renderTask = renderer.RenderRootComponentAsync(componentId, ParameterView.FromDictionary(new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
[nameof(NestedAsyncComponent.EventActions)] = new Dictionary<int, IList<NestedAsyncComponent.ExecutionAction>>
|
[nameof(NestedAsyncComponent.EventActions)] = new Dictionary<int, IList<NestedAsyncComponent.ExecutionAction>>
|
||||||
{
|
{
|
||||||
|
|
@ -2957,7 +2957,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
|
|
||||||
// Act/Assert
|
// Act/Assert
|
||||||
var componentId = renderer.AssignRootComponentId(component);
|
var componentId = renderer.AssignRootComponentId(component);
|
||||||
var renderTask = renderer.RenderRootComponentAsync(componentId, ParameterCollection.FromDictionary(new Dictionary<string, object>
|
var renderTask = renderer.RenderRootComponentAsync(componentId, ParameterView.FromDictionary(new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
[nameof(NestedAsyncComponent.EventActions)] = new Dictionary<int, IList<NestedAsyncComponent.ExecutionAction>>
|
[nameof(NestedAsyncComponent.EventActions)] = new Dictionary<int, IList<NestedAsyncComponent.ExecutionAction>>
|
||||||
{
|
{
|
||||||
|
|
@ -3015,7 +3015,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
|
|
||||||
// Act/Assert
|
// Act/Assert
|
||||||
var componentId = renderer.AssignRootComponentId(component);
|
var componentId = renderer.AssignRootComponentId(component);
|
||||||
var renderTask = renderer.RenderRootComponentAsync(componentId, ParameterCollection.FromDictionary(new Dictionary<string, object>
|
var renderTask = renderer.RenderRootComponentAsync(componentId, ParameterView.FromDictionary(new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
[nameof(NestedAsyncComponent.EventActions)] = new Dictionary<int, IList<NestedAsyncComponent.ExecutionAction>>
|
[nameof(NestedAsyncComponent.EventActions)] = new Dictionary<int, IList<NestedAsyncComponent.ExecutionAction>>
|
||||||
{
|
{
|
||||||
|
|
@ -3070,7 +3070,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
|
|
||||||
// Act/Assert
|
// Act/Assert
|
||||||
var componentId = renderer.AssignRootComponentId(component);
|
var componentId = renderer.AssignRootComponentId(component);
|
||||||
var renderTask = renderer.RenderRootComponentAsync(componentId, ParameterCollection.FromDictionary(new Dictionary<string, object>
|
var renderTask = renderer.RenderRootComponentAsync(componentId, ParameterView.FromDictionary(new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
[nameof(NestedAsyncComponent.EventActions)] = new Dictionary<int, IList<NestedAsyncComponent.ExecutionAction>>
|
[nameof(NestedAsyncComponent.EventActions)] = new Dictionary<int, IList<NestedAsyncComponent.ExecutionAction>>
|
||||||
{
|
{
|
||||||
|
|
@ -3124,7 +3124,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
|
|
||||||
// Act/Assert
|
// Act/Assert
|
||||||
var componentId = renderer.AssignRootComponentId(component);
|
var componentId = renderer.AssignRootComponentId(component);
|
||||||
var renderTask = renderer.RenderRootComponentAsync(componentId, ParameterCollection.FromDictionary(new Dictionary<string, object>
|
var renderTask = renderer.RenderRootComponentAsync(componentId, ParameterView.FromDictionary(new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
[nameof(NestedAsyncComponent.EventActions)] = new Dictionary<int, IList<NestedAsyncComponent.ExecutionAction>>
|
[nameof(NestedAsyncComponent.EventActions)] = new Dictionary<int, IList<NestedAsyncComponent.ExecutionAction>>
|
||||||
{
|
{
|
||||||
|
|
@ -3158,7 +3158,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
|
|
||||||
// Act/Assert
|
// Act/Assert
|
||||||
var componentId = renderer.AssignRootComponentId(component);
|
var componentId = renderer.AssignRootComponentId(component);
|
||||||
var renderTask = renderer.RenderRootComponentAsync(componentId, ParameterCollection.FromDictionary(new Dictionary<string, object>
|
var renderTask = renderer.RenderRootComponentAsync(componentId, ParameterView.FromDictionary(new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
[nameof(NestedAsyncComponent.EventActions)] = new Dictionary<int, IList<NestedAsyncComponent.ExecutionAction>>
|
[nameof(NestedAsyncComponent.EventActions)] = new Dictionary<int, IList<NestedAsyncComponent.ExecutionAction>>
|
||||||
{
|
{
|
||||||
|
|
@ -3195,7 +3195,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
|
|
||||||
// Act/Assert
|
// Act/Assert
|
||||||
var componentId = renderer.AssignRootComponentId(component);
|
var componentId = renderer.AssignRootComponentId(component);
|
||||||
await renderer.RenderRootComponentAsync(componentId, ParameterCollection.FromDictionary(new Dictionary<string, object>
|
await renderer.RenderRootComponentAsync(componentId, ParameterView.FromDictionary(new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
[nameof(NestedAsyncComponent.EventActions)] = new Dictionary<int, IList<NestedAsyncComponent.ExecutionAction>>
|
[nameof(NestedAsyncComponent.EventActions)] = new Dictionary<int, IList<NestedAsyncComponent.ExecutionAction>>
|
||||||
{
|
{
|
||||||
|
|
@ -3428,7 +3428,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
_renderHandle = renderHandle;
|
_renderHandle = renderHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task SetParametersAsync(ParameterCollection parameters)
|
public Task SetParametersAsync(ParameterView parameters)
|
||||||
{
|
{
|
||||||
TriggerRender();
|
TriggerRender();
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|
@ -3497,7 +3497,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
public void Attach(RenderHandle renderHandle)
|
public void Attach(RenderHandle renderHandle)
|
||||||
=> RenderHandle = renderHandle;
|
=> RenderHandle = renderHandle;
|
||||||
|
|
||||||
public Task SetParametersAsync(ParameterCollection parameters)
|
public Task SetParametersAsync(ParameterView parameters)
|
||||||
{
|
{
|
||||||
parameters.SetParameterProperties(this);
|
parameters.SetParameterProperties(this);
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|
@ -3646,7 +3646,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
public void Attach(RenderHandle renderHandle)
|
public void Attach(RenderHandle renderHandle)
|
||||||
=> _renderHandle = renderHandle;
|
=> _renderHandle = renderHandle;
|
||||||
|
|
||||||
public Task SetParametersAsync(ParameterCollection parameters)
|
public Task SetParametersAsync(ParameterView parameters)
|
||||||
{
|
{
|
||||||
parameters.SetParameterProperties(this);
|
parameters.SetParameterProperties(this);
|
||||||
Render();
|
Render();
|
||||||
|
|
@ -3677,7 +3677,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
public void Attach(RenderHandle renderHandle)
|
public void Attach(RenderHandle renderHandle)
|
||||||
=> _renderHandles.Add(renderHandle);
|
=> _renderHandles.Add(renderHandle);
|
||||||
|
|
||||||
public Task SetParametersAsync(ParameterCollection parameters)
|
public Task SetParametersAsync(ParameterView parameters)
|
||||||
{
|
{
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
@ -3734,7 +3734,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
Task IComponent.SetParametersAsync(ParameterCollection parameters)
|
Task IComponent.SetParametersAsync(ParameterView parameters)
|
||||||
{
|
{
|
||||||
TriggerRender();
|
TriggerRender();
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|
@ -3793,7 +3793,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
_renderHandler = renderHandle;
|
_renderHandler = renderHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task SetParametersAsync(ParameterCollection parameters)
|
public async Task SetParametersAsync(ParameterView parameters)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
while (Number > 0)
|
while (Number > 0)
|
||||||
|
|
@ -3842,7 +3842,7 @@ namespace Microsoft.AspNetCore.Components.Test
|
||||||
return task;
|
return task;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task SetParametersAsync(ParameterCollection parameters)
|
public Task SetParametersAsync(ParameterView parameters)
|
||||||
{
|
{
|
||||||
return TriggerRenderAsync();
|
return TriggerRenderAsync();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ namespace Microsoft.AspNetCore.Components.Rendering
|
||||||
var htmlRenderer = GetHtmlRenderer(serviceProvider);
|
var htmlRenderer = GetHtmlRenderer(serviceProvider);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = GetResult(htmlRenderer.Dispatcher.InvokeAsync(() => htmlRenderer.RenderComponentAsync<TestComponent>(ParameterCollection.Empty)));
|
var result = GetResult(htmlRenderer.Dispatcher.InvokeAsync(() => htmlRenderer.RenderComponentAsync<TestComponent>(ParameterView.Empty)));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(expectedHtml, result);
|
Assert.Equal(expectedHtml, result);
|
||||||
|
|
@ -52,7 +52,7 @@ namespace Microsoft.AspNetCore.Components.Rendering
|
||||||
var htmlRenderer = GetHtmlRenderer(serviceProvider);
|
var htmlRenderer = GetHtmlRenderer(serviceProvider);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = GetResult(htmlRenderer.Dispatcher.InvokeAsync(() => htmlRenderer.RenderComponentAsync<TestComponent>(ParameterCollection.Empty)));
|
var result = GetResult(htmlRenderer.Dispatcher.InvokeAsync(() => htmlRenderer.RenderComponentAsync<TestComponent>(ParameterView.Empty)));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(expectedHtml, result);
|
Assert.Equal(expectedHtml, result);
|
||||||
|
|
@ -72,7 +72,7 @@ namespace Microsoft.AspNetCore.Components.Rendering
|
||||||
var htmlRenderer = GetHtmlRenderer(serviceProvider);
|
var htmlRenderer = GetHtmlRenderer(serviceProvider);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = GetResult(htmlRenderer.Dispatcher.InvokeAsync(() => htmlRenderer.RenderComponentAsync<TestComponent>(ParameterCollection.Empty)));
|
var result = GetResult(htmlRenderer.Dispatcher.InvokeAsync(() => htmlRenderer.RenderComponentAsync<TestComponent>(ParameterView.Empty)));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(expectedHtml, result);
|
Assert.Equal(expectedHtml, result);
|
||||||
|
|
@ -93,7 +93,7 @@ namespace Microsoft.AspNetCore.Components.Rendering
|
||||||
var htmlRenderer = GetHtmlRenderer(serviceProvider);
|
var htmlRenderer = GetHtmlRenderer(serviceProvider);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = GetResult(htmlRenderer.Dispatcher.InvokeAsync(() => htmlRenderer.RenderComponentAsync<TestComponent>(ParameterCollection.Empty)));
|
var result = GetResult(htmlRenderer.Dispatcher.InvokeAsync(() => htmlRenderer.RenderComponentAsync<TestComponent>(ParameterView.Empty)));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(expectedHtml, result);
|
Assert.Equal(expectedHtml, result);
|
||||||
|
|
@ -116,7 +116,7 @@ namespace Microsoft.AspNetCore.Components.Rendering
|
||||||
var htmlRenderer = GetHtmlRenderer(serviceProvider);
|
var htmlRenderer = GetHtmlRenderer(serviceProvider);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = GetResult(htmlRenderer.Dispatcher.InvokeAsync(() => htmlRenderer.RenderComponentAsync<TestComponent>(ParameterCollection.Empty)));
|
var result = GetResult(htmlRenderer.Dispatcher.InvokeAsync(() => htmlRenderer.RenderComponentAsync<TestComponent>(ParameterView.Empty)));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(expectedHtml, result);
|
Assert.Equal(expectedHtml, result);
|
||||||
|
|
@ -150,7 +150,7 @@ namespace Microsoft.AspNetCore.Components.Rendering
|
||||||
var htmlRenderer = GetHtmlRenderer(serviceProvider);
|
var htmlRenderer = GetHtmlRenderer(serviceProvider);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = GetResult(htmlRenderer.Dispatcher.InvokeAsync(() => htmlRenderer.RenderComponentAsync<TestComponent>(ParameterCollection.Empty)));
|
var result = GetResult(htmlRenderer.Dispatcher.InvokeAsync(() => htmlRenderer.RenderComponentAsync<TestComponent>(ParameterView.Empty)));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(expectedHtml, result);
|
Assert.Equal(expectedHtml, result);
|
||||||
|
|
@ -172,7 +172,7 @@ namespace Microsoft.AspNetCore.Components.Rendering
|
||||||
var htmlRenderer = GetHtmlRenderer(serviceProvider);
|
var htmlRenderer = GetHtmlRenderer(serviceProvider);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = GetResult(htmlRenderer.Dispatcher.InvokeAsync(() => htmlRenderer.RenderComponentAsync<TestComponent>(ParameterCollection.Empty)));
|
var result = GetResult(htmlRenderer.Dispatcher.InvokeAsync(() => htmlRenderer.RenderComponentAsync<TestComponent>(ParameterView.Empty)));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(expectedHtml, result);
|
Assert.Equal(expectedHtml, result);
|
||||||
|
|
@ -193,7 +193,7 @@ namespace Microsoft.AspNetCore.Components.Rendering
|
||||||
var htmlRenderer = GetHtmlRenderer(serviceProvider);
|
var htmlRenderer = GetHtmlRenderer(serviceProvider);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = GetResult(htmlRenderer.Dispatcher.InvokeAsync(() => htmlRenderer.RenderComponentAsync<TestComponent>(ParameterCollection.Empty)));
|
var result = GetResult(htmlRenderer.Dispatcher.InvokeAsync(() => htmlRenderer.RenderComponentAsync<TestComponent>(ParameterView.Empty)));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(expectedHtml, result);
|
Assert.Equal(expectedHtml, result);
|
||||||
|
|
@ -214,7 +214,7 @@ namespace Microsoft.AspNetCore.Components.Rendering
|
||||||
var htmlRenderer = GetHtmlRenderer(serviceProvider);
|
var htmlRenderer = GetHtmlRenderer(serviceProvider);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = GetResult(htmlRenderer.Dispatcher.InvokeAsync(() => htmlRenderer.RenderComponentAsync<TestComponent>(ParameterCollection.Empty)));
|
var result = GetResult(htmlRenderer.Dispatcher.InvokeAsync(() => htmlRenderer.RenderComponentAsync<TestComponent>(ParameterView.Empty)));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(expectedHtml, result);
|
Assert.Equal(expectedHtml, result);
|
||||||
|
|
@ -237,7 +237,7 @@ namespace Microsoft.AspNetCore.Components.Rendering
|
||||||
var htmlRenderer = GetHtmlRenderer(serviceProvider);
|
var htmlRenderer = GetHtmlRenderer(serviceProvider);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = GetResult(htmlRenderer.Dispatcher.InvokeAsync(() => htmlRenderer.RenderComponentAsync<TestComponent>(ParameterCollection.Empty)));
|
var result = GetResult(htmlRenderer.Dispatcher.InvokeAsync(() => htmlRenderer.RenderComponentAsync<TestComponent>(ParameterView.Empty)));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(expectedHtml, result);
|
Assert.Equal(expectedHtml, result);
|
||||||
|
|
@ -267,7 +267,7 @@ namespace Microsoft.AspNetCore.Components.Rendering
|
||||||
var htmlRenderer = GetHtmlRenderer(serviceProvider);
|
var htmlRenderer = GetHtmlRenderer(serviceProvider);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = GetResult(htmlRenderer.Dispatcher.InvokeAsync(() => htmlRenderer.RenderComponentAsync<TestComponent>(ParameterCollection.Empty)));
|
var result = GetResult(htmlRenderer.Dispatcher.InvokeAsync(() => htmlRenderer.RenderComponentAsync<TestComponent>(ParameterView.Empty)));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(expectedHtml, result);
|
Assert.Equal(expectedHtml, result);
|
||||||
|
|
@ -296,7 +296,7 @@ namespace Microsoft.AspNetCore.Components.Rendering
|
||||||
var htmlRenderer = GetHtmlRenderer(serviceProvider);
|
var htmlRenderer = GetHtmlRenderer(serviceProvider);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = GetResult(htmlRenderer.Dispatcher.InvokeAsync(() => htmlRenderer.RenderComponentAsync<TestComponent>(ParameterCollection.Empty)));
|
var result = GetResult(htmlRenderer.Dispatcher.InvokeAsync(() => htmlRenderer.RenderComponentAsync<TestComponent>(ParameterView.Empty)));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(expectedHtml, result);
|
Assert.Equal(expectedHtml, result);
|
||||||
|
|
@ -326,7 +326,7 @@ namespace Microsoft.AspNetCore.Components.Rendering
|
||||||
var htmlRenderer = GetHtmlRenderer(serviceProvider);
|
var htmlRenderer = GetHtmlRenderer(serviceProvider);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = GetResult(htmlRenderer.Dispatcher.InvokeAsync(() => htmlRenderer.RenderComponentAsync<TestComponent>(ParameterCollection.Empty)));
|
var result = GetResult(htmlRenderer.Dispatcher.InvokeAsync(() => htmlRenderer.RenderComponentAsync<TestComponent>(ParameterView.Empty)));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(expectedHtml, result);
|
Assert.Equal(expectedHtml, result);
|
||||||
|
|
@ -339,7 +339,7 @@ namespace Microsoft.AspNetCore.Components.Rendering
|
||||||
var expectedHtml = new[] {
|
var expectedHtml = new[] {
|
||||||
"<", "p", ">", "<", "input", " ", "value", "=", "\"", "5", "\"", " />", "</", "p", ">" };
|
"<", "p", ">", "<", "input", " ", "value", "=", "\"", "5", "\"", " />", "</", "p", ">" };
|
||||||
|
|
||||||
RenderFragment Content(ParameterCollection pc) => new RenderFragment((RenderTreeBuilder rtb) =>
|
RenderFragment Content(ParameterView pc) => new RenderFragment((RenderTreeBuilder rtb) =>
|
||||||
{
|
{
|
||||||
rtb.OpenElement(0, "p");
|
rtb.OpenElement(0, "p");
|
||||||
rtb.OpenElement(1, "input");
|
rtb.OpenElement(1, "input");
|
||||||
|
|
@ -350,7 +350,7 @@ namespace Microsoft.AspNetCore.Components.Rendering
|
||||||
});
|
});
|
||||||
|
|
||||||
var serviceProvider = new ServiceCollection()
|
var serviceProvider = new ServiceCollection()
|
||||||
.AddSingleton(new Func<ParameterCollection, RenderFragment>(Content))
|
.AddSingleton(new Func<ParameterView, RenderFragment>(Content))
|
||||||
.BuildServiceProvider();
|
.BuildServiceProvider();
|
||||||
|
|
||||||
var htmlRenderer = GetHtmlRenderer(serviceProvider);
|
var htmlRenderer = GetHtmlRenderer(serviceProvider);
|
||||||
|
|
@ -358,7 +358,7 @@ namespace Microsoft.AspNetCore.Components.Rendering
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = GetResult(htmlRenderer.Dispatcher.InvokeAsync(() => htmlRenderer.RenderComponentAsync<ComponentWithParameters>(
|
var result = GetResult(htmlRenderer.Dispatcher.InvokeAsync(() => htmlRenderer.RenderComponentAsync<ComponentWithParameters>(
|
||||||
new ParameterCollection(new[] {
|
new ParameterView(new[] {
|
||||||
RenderTreeFrame.Element(0,string.Empty),
|
RenderTreeFrame.Element(0,string.Empty),
|
||||||
RenderTreeFrame.Attribute(1,"update",change),
|
RenderTreeFrame.Attribute(1,"update",change),
|
||||||
RenderTreeFrame.Attribute(2,"value",5)
|
RenderTreeFrame.Attribute(2,"value",5)
|
||||||
|
|
@ -388,7 +388,7 @@ namespace Microsoft.AspNetCore.Components.Rendering
|
||||||
var htmlRenderer = GetHtmlRenderer(serviceProvider);
|
var htmlRenderer = GetHtmlRenderer(serviceProvider);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = GetResult(htmlRenderer.Dispatcher.InvokeAsync(() => htmlRenderer.RenderComponentAsync<TestComponent>(ParameterCollection.Empty)));
|
var result = GetResult(htmlRenderer.Dispatcher.InvokeAsync(() => htmlRenderer.RenderComponentAsync<TestComponent>(ParameterView.Empty)));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(expectedHtml, result);
|
Assert.Equal(expectedHtml, result);
|
||||||
|
|
@ -415,7 +415,7 @@ namespace Microsoft.AspNetCore.Components.Rendering
|
||||||
var htmlRenderer = GetHtmlRenderer(serviceProvider);
|
var htmlRenderer = GetHtmlRenderer(serviceProvider);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = GetResult(htmlRenderer.Dispatcher.InvokeAsync(() => htmlRenderer.RenderComponentAsync<TestComponent>(ParameterCollection.Empty)));
|
var result = GetResult(htmlRenderer.Dispatcher.InvokeAsync(() => htmlRenderer.RenderComponentAsync<TestComponent>(ParameterView.Empty)));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(expectedHtml, result);
|
Assert.Equal(expectedHtml, result);
|
||||||
|
|
@ -445,9 +445,9 @@ namespace Microsoft.AspNetCore.Components.Rendering
|
||||||
}
|
}
|
||||||
|
|
||||||
[Inject]
|
[Inject]
|
||||||
Func<ParameterCollection, RenderFragment> CreateRenderFragment { get; set; }
|
Func<ParameterView, RenderFragment> CreateRenderFragment { get; set; }
|
||||||
|
|
||||||
public Task SetParametersAsync(ParameterCollection parameters)
|
public Task SetParametersAsync(ParameterView parameters)
|
||||||
{
|
{
|
||||||
RenderHandle.Render(CreateRenderFragment(parameters));
|
RenderHandle.Render(CreateRenderFragment(parameters));
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|
@ -465,7 +465,7 @@ namespace Microsoft.AspNetCore.Components.Rendering
|
||||||
var htmlRenderer = GetHtmlRenderer(serviceProvider);
|
var htmlRenderer = GetHtmlRenderer(serviceProvider);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = await htmlRenderer.Dispatcher.InvokeAsync(() => htmlRenderer.RenderComponentAsync<AsyncComponent>(ParameterCollection.FromDictionary(new Dictionary<string, object>
|
var result = await htmlRenderer.Dispatcher.InvokeAsync(() => htmlRenderer.RenderComponentAsync<AsyncComponent>(ParameterView.FromDictionary(new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
["Value"] = 10
|
["Value"] = 10
|
||||||
})));
|
})));
|
||||||
|
|
@ -489,7 +489,7 @@ namespace Microsoft.AspNetCore.Components.Rendering
|
||||||
var htmlRenderer = GetHtmlRenderer(serviceProvider);
|
var htmlRenderer = GetHtmlRenderer(serviceProvider);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = await htmlRenderer.Dispatcher.InvokeAsync(() => htmlRenderer.RenderComponentAsync<NestedAsyncComponent>(ParameterCollection.FromDictionary(new Dictionary<string, object>
|
var result = await htmlRenderer.Dispatcher.InvokeAsync(() => htmlRenderer.RenderComponentAsync<NestedAsyncComponent>(ParameterView.FromDictionary(new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
["Nested"] = false,
|
["Nested"] = false,
|
||||||
["Value"] = 10
|
["Value"] = 10
|
||||||
|
|
@ -558,13 +558,13 @@ namespace Microsoft.AspNetCore.Components.Rendering
|
||||||
_renderHandle = renderHandle;
|
_renderHandle = renderHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task SetParametersAsync(ParameterCollection parameters)
|
public Task SetParametersAsync(ParameterView parameters)
|
||||||
{
|
{
|
||||||
_renderHandle.Render(CreateRenderFragment(parameters));
|
_renderHandle.Render(CreateRenderFragment(parameters));
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
private RenderFragment CreateRenderFragment(ParameterCollection parameters)
|
private RenderFragment CreateRenderFragment(ParameterView parameters)
|
||||||
{
|
{
|
||||||
return RenderFragment;
|
return RenderFragment;
|
||||||
|
|
||||||
|
|
@ -589,7 +589,7 @@ namespace Microsoft.AspNetCore.Components.Rendering
|
||||||
_renderHandle = renderHandle;
|
_renderHandle = renderHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task SetParametersAsync(ParameterCollection parameters)
|
public Task SetParametersAsync(ParameterView parameters)
|
||||||
{
|
{
|
||||||
_renderHandle.Render(Fragment);
|
_renderHandle.Render(Fragment);
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ namespace Microsoft.AspNetCore.Components.Server
|
||||||
public ComponentPrerenderingContext() { }
|
public ComponentPrerenderingContext() { }
|
||||||
public System.Type ComponentType { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
|
public System.Type ComponentType { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
|
||||||
public Microsoft.AspNetCore.Http.HttpContext Context { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
|
public Microsoft.AspNetCore.Http.HttpContext Context { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
|
||||||
public Microsoft.AspNetCore.Components.ParameterCollection Parameters { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
|
public Microsoft.AspNetCore.Components.ParameterView Parameters { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
|
||||||
}
|
}
|
||||||
public sealed partial class ComponentPrerenderResult
|
public sealed partial class ComponentPrerenderResult
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ namespace Microsoft.AspNetCore.Components.Server.Circuits
|
||||||
|
|
||||||
public IServiceProvider Services { get; }
|
public IServiceProvider Services { get; }
|
||||||
|
|
||||||
public Task<ComponentRenderedText> PrerenderComponentAsync(Type componentType, ParameterCollection parameters)
|
public Task<ComponentRenderedText> PrerenderComponentAsync(Type componentType, ParameterView parameters)
|
||||||
{
|
{
|
||||||
return Renderer.Dispatcher.InvokeAsync(async () =>
|
return Renderer.Dispatcher.InvokeAsync(async () =>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ namespace Microsoft.AspNetCore.Components.Server
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the parameters for the component.
|
/// Gets or sets the parameters for the component.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ParameterCollection Parameters { get; set; }
|
public ParameterView Parameters { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the <see cref="HttpContext"/> in which the prerendering has been initiated.
|
/// Gets or sets the <see cref="HttpContext"/> in which the prerendering has been initiated.
|
||||||
|
|
|
||||||
|
|
@ -275,7 +275,7 @@ namespace Microsoft.AspNetCore.Components.Server.Circuits
|
||||||
public bool DidCallDispose { get; private set; }
|
public bool DidCallDispose { get; private set; }
|
||||||
public void Attach(RenderHandle renderHandle) { }
|
public void Attach(RenderHandle renderHandle) { }
|
||||||
|
|
||||||
public Task SetParametersAsync(ParameterCollection parameters)
|
public Task SetParametersAsync(ParameterView parameters)
|
||||||
=> Task.CompletedTask;
|
=> Task.CompletedTask;
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ namespace Microsoft.AspNetCore.Components.Server.Tests.Circuits
|
||||||
var prerenderingContext = new ComponentPrerenderingContext
|
var prerenderingContext = new ComponentPrerenderingContext
|
||||||
{
|
{
|
||||||
ComponentType = typeof(UriDisplayComponent),
|
ComponentType = typeof(UriDisplayComponent),
|
||||||
Parameters = ParameterCollection.Empty,
|
Parameters = ParameterView.Empty,
|
||||||
Context = httpContext
|
Context = httpContext
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -109,7 +109,7 @@ namespace Microsoft.AspNetCore.Components.Server.Tests.Circuits
|
||||||
var prerenderingContext = new ComponentPrerenderingContext
|
var prerenderingContext = new ComponentPrerenderingContext
|
||||||
{
|
{
|
||||||
ComponentType = typeof(UriDisplayComponent),
|
ComponentType = typeof(UriDisplayComponent),
|
||||||
Parameters = ParameterCollection.Empty,
|
Parameters = ParameterView.Empty,
|
||||||
Context = httpContext
|
Context = httpContext
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -145,7 +145,7 @@ namespace Microsoft.AspNetCore.Components.Server.Tests.Circuits
|
||||||
var prerenderingContext = new ComponentPrerenderingContext
|
var prerenderingContext = new ComponentPrerenderingContext
|
||||||
{
|
{
|
||||||
ComponentType = typeof(UriDisplayComponent),
|
ComponentType = typeof(UriDisplayComponent),
|
||||||
Parameters = ParameterCollection.Empty,
|
Parameters = ParameterView.Empty,
|
||||||
Context = httpContext
|
Context = httpContext
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -170,7 +170,7 @@ namespace Microsoft.AspNetCore.Components.Server.Tests.Circuits
|
||||||
var prerenderingContext = new ComponentPrerenderingContext
|
var prerenderingContext = new ComponentPrerenderingContext
|
||||||
{
|
{
|
||||||
ComponentType = typeof(ThrowExceptionComponent),
|
ComponentType = typeof(ThrowExceptionComponent),
|
||||||
Parameters = ParameterCollection.Empty,
|
Parameters = ParameterView.Empty,
|
||||||
Context = httpContext
|
Context = httpContext
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -227,7 +227,7 @@ namespace Microsoft.AspNetCore.Components.Server.Tests.Circuits
|
||||||
_renderHandle = renderHandle;
|
_renderHandle = renderHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task SetParametersAsync(ParameterCollection parameters)
|
public Task SetParametersAsync(ParameterView parameters)
|
||||||
{
|
{
|
||||||
_renderHandle.Render(builder =>
|
_renderHandle.Render(builder =>
|
||||||
{
|
{
|
||||||
|
|
@ -246,7 +246,7 @@ namespace Microsoft.AspNetCore.Components.Server.Tests.Circuits
|
||||||
public void Attach(RenderHandle renderHandle)
|
public void Attach(RenderHandle renderHandle)
|
||||||
=> throw new InvalidTimeZoneException();
|
=> throw new InvalidTimeZoneException();
|
||||||
|
|
||||||
public Task SetParametersAsync(ParameterCollection parameters)
|
public Task SetParametersAsync(ParameterView parameters)
|
||||||
=> Task.CompletedTask;
|
=> Task.CompletedTask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ namespace Microsoft.AspNetCore.Components.Web.Rendering
|
||||||
|
|
||||||
// This produces the initial batch (id = 2)
|
// This produces the initial batch (id = 2)
|
||||||
var result = await renderer.RenderComponentAsync<AutoParameterTestComponent>(
|
var result = await renderer.RenderComponentAsync<AutoParameterTestComponent>(
|
||||||
ParameterCollection.FromDictionary(new Dictionary<string, object>
|
ParameterView.FromDictionary(new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
[nameof(AutoParameterTestComponent.Content)] = initialContent,
|
[nameof(AutoParameterTestComponent.Content)] = initialContent,
|
||||||
[nameof(AutoParameterTestComponent.Trigger)] = trigger
|
[nameof(AutoParameterTestComponent.Trigger)] = trigger
|
||||||
|
|
@ -202,7 +202,7 @@ namespace Microsoft.AspNetCore.Components.Web.Rendering
|
||||||
|
|
||||||
// This produces the initial batch (id = 2)
|
// This produces the initial batch (id = 2)
|
||||||
var result = await renderer.RenderComponentAsync<AutoParameterTestComponent>(
|
var result = await renderer.RenderComponentAsync<AutoParameterTestComponent>(
|
||||||
ParameterCollection.FromDictionary(new Dictionary<string, object>
|
ParameterView.FromDictionary(new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
[nameof(AutoParameterTestComponent.Content)] = initialContent,
|
[nameof(AutoParameterTestComponent.Content)] = initialContent,
|
||||||
[nameof(AutoParameterTestComponent.Trigger)] = trigger
|
[nameof(AutoParameterTestComponent.Trigger)] = trigger
|
||||||
|
|
@ -265,7 +265,7 @@ namespace Microsoft.AspNetCore.Components.Web.Rendering
|
||||||
|
|
||||||
// This produces the initial batch (id = 2)
|
// This produces the initial batch (id = 2)
|
||||||
var result = await renderer.RenderComponentAsync<AutoParameterTestComponent>(
|
var result = await renderer.RenderComponentAsync<AutoParameterTestComponent>(
|
||||||
ParameterCollection.FromDictionary(new Dictionary<string, object>
|
ParameterView.FromDictionary(new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
[nameof(AutoParameterTestComponent.Content)] = initialContent,
|
[nameof(AutoParameterTestComponent.Content)] = initialContent,
|
||||||
[nameof(AutoParameterTestComponent.Trigger)] = trigger
|
[nameof(AutoParameterTestComponent.Trigger)] = trigger
|
||||||
|
|
@ -322,7 +322,7 @@ namespace Microsoft.AspNetCore.Components.Web.Rendering
|
||||||
|
|
||||||
// This produces the initial batch (id = 2)
|
// This produces the initial batch (id = 2)
|
||||||
var result = await renderer.RenderComponentAsync<AutoParameterTestComponent>(
|
var result = await renderer.RenderComponentAsync<AutoParameterTestComponent>(
|
||||||
ParameterCollection.FromDictionary(new Dictionary<string, object>
|
ParameterView.FromDictionary(new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
[nameof(AutoParameterTestComponent.Content)] = initialContent,
|
[nameof(AutoParameterTestComponent.Content)] = initialContent,
|
||||||
[nameof(AutoParameterTestComponent.Trigger)] = trigger
|
[nameof(AutoParameterTestComponent.Trigger)] = trigger
|
||||||
|
|
@ -366,8 +366,8 @@ namespace Microsoft.AspNetCore.Components.Web.Rendering
|
||||||
new CircuitClientProxy());
|
new CircuitClientProxy());
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var first = await renderer.RenderComponentAsync<TestComponent>(ParameterCollection.Empty);
|
var first = await renderer.RenderComponentAsync<TestComponent>(ParameterView.Empty);
|
||||||
var second = await renderer.RenderComponentAsync<TestComponent>(ParameterCollection.Empty);
|
var second = await renderer.RenderComponentAsync<TestComponent>(ParameterView.Empty);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(0, first.ComponentId);
|
Assert.Equal(0, first.ComponentId);
|
||||||
|
|
@ -427,7 +427,7 @@ namespace Microsoft.AspNetCore.Components.Web.Rendering
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task SetParametersAsync(ParameterCollection parameters)
|
public Task SetParametersAsync(ParameterView parameters)
|
||||||
{
|
{
|
||||||
TriggerRender();
|
TriggerRender();
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|
@ -453,7 +453,7 @@ namespace Microsoft.AspNetCore.Components.Web.Rendering
|
||||||
_renderHandle = renderHandle;
|
_renderHandle = renderHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task SetParametersAsync(ParameterCollection parameters)
|
public Task SetParametersAsync(ParameterView parameters)
|
||||||
{
|
{
|
||||||
Content = parameters.GetValueOrDefault<RenderFragment>(nameof(Content));
|
Content = parameters.GetValueOrDefault<RenderFragment>(nameof(Content));
|
||||||
Trigger ??= parameters.GetValueOrDefault<Trigger>(nameof(Trigger));
|
Trigger ??= parameters.GetValueOrDefault<Trigger>(nameof(Trigger));
|
||||||
|
|
|
||||||
|
|
@ -374,7 +374,7 @@ namespace Microsoft.AspNetCore.Components.Server
|
||||||
public void Attach(RenderHandle renderHandle)
|
public void Attach(RenderHandle renderHandle)
|
||||||
=> throw new NotImplementedException();
|
=> throw new NotImplementedException();
|
||||||
|
|
||||||
public Task SetParametersAsync(ParameterCollection parameters)
|
public Task SetParametersAsync(ParameterView parameters)
|
||||||
=> throw new NotImplementedException();
|
=> throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ namespace Microsoft.AspNetCore.Components.Test.Helpers
|
||||||
_renderHandle = renderHandle;
|
_renderHandle = renderHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual Task SetParametersAsync(ParameterCollection parameters)
|
public virtual Task SetParametersAsync(ParameterView parameters)
|
||||||
{
|
{
|
||||||
parameters.SetParameterProperties(this);
|
parameters.SetParameterProperties(this);
|
||||||
TriggerRender();
|
TriggerRender();
|
||||||
|
|
|
||||||
|
|
@ -13,27 +13,7 @@ namespace Microsoft.AspNetCore.Components.Test.Helpers
|
||||||
this IComponent component,
|
this IComponent component,
|
||||||
Dictionary<string, object> parameters)
|
Dictionary<string, object> parameters)
|
||||||
{
|
{
|
||||||
component.SetParametersAsync(DictionaryToParameterCollection(parameters));
|
component.SetParametersAsync(ParameterView.FromDictionary(parameters));
|
||||||
}
|
|
||||||
|
|
||||||
private static ParameterCollection DictionaryToParameterCollection(
|
|
||||||
IDictionary<string, object> parameters)
|
|
||||||
{
|
|
||||||
var builder = new RenderTreeBuilder();
|
|
||||||
builder.OpenComponent<AbstractComponent>(0);
|
|
||||||
foreach (var pair in parameters)
|
|
||||||
{
|
|
||||||
builder.AddAttribute(0, pair.Key, pair.Value);
|
|
||||||
}
|
|
||||||
builder.CloseElement();
|
|
||||||
|
|
||||||
return new ParameterCollection(builder.GetFrames().Array, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private abstract class AbstractComponent : IComponent
|
|
||||||
{
|
|
||||||
public abstract void Attach(RenderHandle renderHandle);
|
|
||||||
public abstract Task SetParametersAsync(ParameterCollection parameters);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,16 +48,16 @@ namespace Microsoft.AspNetCore.Components.Test.Helpers
|
||||||
public new int AssignRootComponentId(IComponent component)
|
public new int AssignRootComponentId(IComponent component)
|
||||||
=> base.AssignRootComponentId(component);
|
=> base.AssignRootComponentId(component);
|
||||||
|
|
||||||
public void RenderRootComponent(int componentId, ParameterCollection? parameters = default)
|
public void RenderRootComponent(int componentId, ParameterView? parameters = default)
|
||||||
{
|
{
|
||||||
var task = Dispatcher.InvokeAsync(() => base.RenderRootComponentAsync(componentId, parameters ?? ParameterCollection.Empty));
|
var task = Dispatcher.InvokeAsync(() => base.RenderRootComponentAsync(componentId, parameters ?? ParameterView.Empty));
|
||||||
UnwrapTask(task);
|
UnwrapTask(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
public new Task RenderRootComponentAsync(int componentId)
|
public new Task RenderRootComponentAsync(int componentId)
|
||||||
=> Dispatcher.InvokeAsync(() => base.RenderRootComponentAsync(componentId));
|
=> Dispatcher.InvokeAsync(() => base.RenderRootComponentAsync(componentId));
|
||||||
|
|
||||||
public new Task RenderRootComponentAsync(int componentId, ParameterCollection parameters)
|
public new Task RenderRootComponentAsync(int componentId, ParameterView parameters)
|
||||||
=> Dispatcher.InvokeAsync(() => base.RenderRootComponentAsync(componentId, parameters));
|
=> Dispatcher.InvokeAsync(() => base.RenderRootComponentAsync(componentId, parameters));
|
||||||
|
|
||||||
public Task DispatchEventAsync(ulong eventHandlerId, UIEventArgs args)
|
public Task DispatchEventAsync(ulong eventHandlerId, UIEventArgs args)
|
||||||
|
|
|
||||||
|
|
@ -317,7 +317,7 @@ namespace Microsoft.AspNetCore.Components.Forms
|
||||||
[Microsoft.AspNetCore.Components.ParameterAttribute]
|
[Microsoft.AspNetCore.Components.ParameterAttribute]
|
||||||
public System.Linq.Expressions.Expression<System.Func<T>> ValueExpression { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
|
public System.Linq.Expressions.Expression<System.Func<T>> ValueExpression { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
|
||||||
protected virtual string FormatValueAsString(T value) { throw null; }
|
protected virtual string FormatValueAsString(T value) { throw null; }
|
||||||
public override System.Threading.Tasks.Task SetParametersAsync(Microsoft.AspNetCore.Components.ParameterCollection parameters) { throw null; }
|
public override System.Threading.Tasks.Task SetParametersAsync(Microsoft.AspNetCore.Components.ParameterView parameters) { throw null; }
|
||||||
protected abstract bool TryParseValueFromString(string value, out T result, out string validationErrorMessage);
|
protected abstract bool TryParseValueFromString(string value, out T result, out string validationErrorMessage);
|
||||||
}
|
}
|
||||||
public partial class InputCheckbox : Microsoft.AspNetCore.Components.Forms.InputBase<bool>
|
public partial class InputCheckbox : Microsoft.AspNetCore.Components.Forms.InputBase<bool>
|
||||||
|
|
|
||||||
|
|
@ -168,7 +168,7 @@ namespace Microsoft.AspNetCore.Components.Forms
|
||||||
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override Task SetParametersAsync(ParameterCollection parameters)
|
public override Task SetParametersAsync(ParameterView parameters)
|
||||||
{
|
{
|
||||||
parameters.SetParameterProperties(this);
|
parameters.SetParameterProperties(this);
|
||||||
|
|
||||||
|
|
@ -206,7 +206,7 @@ namespace Microsoft.AspNetCore.Components.Forms
|
||||||
}
|
}
|
||||||
|
|
||||||
// For derived components, retain the usual lifecycle with OnInit/OnParametersSet/etc.
|
// For derived components, retain the usual lifecycle with OnInit/OnParametersSet/etc.
|
||||||
return base.SetParametersAsync(ParameterCollection.Empty);
|
return base.SetParametersAsync(ParameterView.Empty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -331,7 +331,7 @@ namespace Ignitor
|
||||||
public void Attach(RenderHandle renderHandle)
|
public void Attach(RenderHandle renderHandle)
|
||||||
=> throw new NotImplementedException();
|
=> throw new NotImplementedException();
|
||||||
|
|
||||||
public Task SetParametersAsync(ParameterCollection parameters)
|
public Task SetParametersAsync(ParameterView parameters)
|
||||||
=> throw new NotImplementedException();
|
=> throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -310,7 +310,7 @@ namespace Ignitor
|
||||||
public void Attach(RenderHandle renderHandle)
|
public void Attach(RenderHandle renderHandle)
|
||||||
=> throw new NotImplementedException();
|
=> throw new NotImplementedException();
|
||||||
|
|
||||||
public Task SetParametersAsync(ParameterCollection parameters)
|
public Task SetParametersAsync(ParameterView parameters)
|
||||||
=> throw new NotImplementedException();
|
=> throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,8 +58,8 @@ namespace Microsoft.AspNetCore.Mvc.Rendering
|
||||||
}
|
}
|
||||||
|
|
||||||
var parametersCollection = parameters == null ?
|
var parametersCollection = parameters == null ?
|
||||||
ParameterCollection.Empty :
|
ParameterView.Empty :
|
||||||
ParameterCollection.FromDictionary(HtmlHelper.ObjectToDictionary(parameters));
|
ParameterView.FromDictionary(HtmlHelper.ObjectToDictionary(parameters));
|
||||||
|
|
||||||
var result = await prerenderer.PrerenderComponentAsync(
|
var result = await prerenderer.PrerenderComponentAsync(
|
||||||
new ComponentPrerenderingContext
|
new ComponentPrerenderingContext
|
||||||
|
|
|
||||||
|
|
@ -277,7 +277,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
|
||||||
_renderHandle = renderHandle;
|
_renderHandle = renderHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task SetParametersAsync(ParameterCollection parameters)
|
public Task SetParametersAsync(ParameterView parameters)
|
||||||
{
|
{
|
||||||
_renderHandle.Render(builder =>
|
_renderHandle.Render(builder =>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -52,8 +52,8 @@ namespace Microsoft.AspNetCore.Mvc.Rendering
|
||||||
var prerenderer = serviceProvider.GetRequiredService<StaticComponentRenderer>();
|
var prerenderer = serviceProvider.GetRequiredService<StaticComponentRenderer>();
|
||||||
|
|
||||||
var parametersCollection = parameters == null ?
|
var parametersCollection = parameters == null ?
|
||||||
ParameterCollection.Empty :
|
ParameterView.Empty :
|
||||||
ParameterCollection.FromDictionary(HtmlHelper.ObjectToDictionary(parameters));
|
ParameterView.FromDictionary(HtmlHelper.ObjectToDictionary(parameters));
|
||||||
|
|
||||||
var result = await prerenderer.PrerenderComponentAsync(
|
var result = await prerenderer.PrerenderComponentAsync(
|
||||||
parametersCollection,
|
parametersCollection,
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures.RazorComponents
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<string>> PrerenderComponentAsync(
|
public async Task<IEnumerable<string>> PrerenderComponentAsync(
|
||||||
ParameterCollection parameters,
|
ParameterView parameters,
|
||||||
HttpContext httpContext,
|
HttpContext httpContext,
|
||||||
Type componentType)
|
Type componentType)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -256,7 +256,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Test
|
||||||
_renderHandle = renderHandle;
|
_renderHandle = renderHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task SetParametersAsync(ParameterCollection parameters)
|
public Task SetParametersAsync(ParameterView parameters)
|
||||||
{
|
{
|
||||||
_renderHandle.Render(builder =>
|
_renderHandle.Render(builder =>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue