File tree Expand file tree Collapse file tree 4 files changed +20
-0
lines changed
src/Components/Components/src Expand file tree Collapse file tree 4 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ namespace Microsoft.AspNetCore.Components;
23
23
public abstract class ComponentBase : IComponent , IHandleEvent , IHandleAfterRender
24
24
{
25
25
private readonly RenderFragment _renderFragment ;
26
+ private IComponentRenderMode ? _interactiveRenderMode ;
26
27
private RenderHandle _renderHandle ;
27
28
private bool _initialized ;
28
29
private bool _hasNeverRendered = true ;
@@ -47,6 +48,11 @@ public ComponentBase()
47
48
/// </summary>
48
49
protected ComponentPlatform Platform => _renderHandle . Platform ;
49
50
51
+ /// <summary>
52
+ /// Gets the <see cref="IComponentRenderMode"/> the component is rendering or will render in when it becomes interactive.
53
+ /// </summary>
54
+ protected IComponentRenderMode ? InteractiveRenderMode => _interactiveRenderMode ??= _renderHandle . GetInteractiveRenderMode ( ) ;
55
+
50
56
/// <summary>
51
57
/// Renders the component to the supplied <see cref="RenderTreeBuilder"/>.
52
58
/// </summary>
Original file line number Diff line number Diff line change 1
1
#nullable enable
2
+ Microsoft.AspNetCore.Components.ComponentBase.InteractiveRenderMode.get -> Microsoft.AspNetCore.Components.IComponentRenderMode?
2
3
Microsoft.AspNetCore.Components.ComponentBase.Platform.get -> Microsoft.AspNetCore.Components.RenderTree.ComponentPlatform!
3
4
Microsoft.AspNetCore.Components.ExcludeFromInteractiveRoutingAttribute
4
5
Microsoft.AspNetCore.Components.ExcludeFromInteractiveRoutingAttribute.ExcludeFromInteractiveRoutingAttribute() -> void
Original file line number Diff line number Diff line change @@ -56,6 +56,16 @@ public Dispatcher Dispatcher
56
56
/// </summary>
57
57
public ComponentPlatform Platform => _renderer ? . ComponentPlatform ?? throw new InvalidOperationException ( "No renderer has been initialized." ) ;
58
58
59
+ internal IComponentRenderMode ? GetInteractiveRenderMode ( )
60
+ {
61
+ if ( _renderer == null )
62
+ {
63
+ throw new InvalidOperationException ( "No renderer has been initialized." ) ;
64
+ }
65
+
66
+ return _renderer . ComponentPlatform . RenderMode ?? _renderer . GetComponentRenderMode ( _componentId ) ;
67
+ }
68
+
59
69
/// <summary>
60
70
/// Notifies the renderer that the component should be rendered.
61
71
/// </summary>
Original file line number Diff line number Diff line change @@ -142,6 +142,9 @@ protected ComponentState GetComponentState(int componentId)
142
142
protected internal virtual IComponentRenderMode ? GetComponentRenderMode ( IComponent component )
143
143
=> null ;
144
144
145
+ internal IComponentRenderMode ? GetComponentRenderMode ( int componentId )
146
+ => GetComponentRenderMode ( GetRequiredComponentState ( componentId ) . Component ) ;
147
+
145
148
/// <summary>
146
149
/// Resolves the component state for a given <see cref="IComponent"/> instance.
147
150
/// </summary>
You can’t perform that action at this time.
0 commit comments