7
7
using System . Text . Json ;
8
8
using System . Threading ;
9
9
using System . Threading . Tasks ;
10
- using Microsoft . AspNetCore . Components . Rendering ;
11
- using Microsoft . AspNetCore . Components . Routing ;
12
10
using Microsoft . AspNetCore . Components . Web ;
13
11
using Microsoft . AspNetCore . Components . Web . Rendering ;
14
12
using Microsoft . Extensions . DependencyInjection ;
@@ -57,7 +55,7 @@ public CircuitHost(
57
55
CircuitClientProxy client ,
58
56
RendererRegistry rendererRegistry ,
59
57
RemoteRenderer renderer ,
60
- IList < ComponentDescriptor > descriptors ,
58
+ IReadOnlyList < ComponentDescriptor > descriptors ,
61
59
RemoteJSRuntime jsRuntime ,
62
60
CircuitHandler [ ] circuitHandlers ,
63
61
ILogger logger )
@@ -92,24 +90,10 @@ public CircuitHost(
92
90
93
91
public RendererRegistry RendererRegistry { get ; }
94
92
95
- public IList < ComponentDescriptor > Descriptors { get ; }
93
+ public IReadOnlyList < ComponentDescriptor > Descriptors { get ; }
96
94
97
95
public IServiceProvider Services { get ; }
98
96
99
- public Task < ComponentRenderedText > PrerenderComponentAsync ( Type componentType , ParameterView parameters )
100
- {
101
- return Renderer . Dispatcher . InvokeAsync ( async ( ) =>
102
- {
103
- var result = await Renderer . RenderComponentAsync ( componentType , parameters ) ;
104
-
105
- // When we prerender we start the circuit in a disconnected state. As such, we only call
106
- // OnCircuitOpenenedAsync here and when the client reconnects we run OnConnectionUpAsync
107
- await OnCircuitOpenedAsync ( CancellationToken . None ) ;
108
-
109
- return result ;
110
- } ) ;
111
- }
112
-
113
97
public void SetCircuitUser ( ClaimsPrincipal user )
114
98
{
115
99
var authenticationStateProvider = Services . GetService < AuthenticationStateProvider > ( ) as IHostEnvironmentAuthenticationStateProvider ;
@@ -120,26 +104,6 @@ public void SetCircuitUser(ClaimsPrincipal user)
120
104
}
121
105
}
122
106
123
- internal void InitializeCircuitAfterPrerender ( UnhandledExceptionEventHandler unhandledException )
124
- {
125
- if ( ! _initialized )
126
- {
127
- _initialized = true ;
128
- UnhandledException += unhandledException ;
129
- var uriHelper = ( RemoteUriHelper ) Services . GetRequiredService < IUriHelper > ( ) ;
130
- if ( ! uriHelper . HasAttachedJSRuntime )
131
- {
132
- uriHelper . AttachJsRuntime ( JSRuntime ) ;
133
- }
134
-
135
- var navigationInterception = ( RemoteNavigationInterception ) Services . GetRequiredService < INavigationInterception > ( ) ;
136
- if ( ! navigationInterception . HasAttachedJSRuntime )
137
- {
138
- navigationInterception . AttachJSRuntime ( JSRuntime ) ;
139
- }
140
- }
141
- }
142
-
143
107
internal void SendPendingBatches ( )
144
108
{
145
109
// Dispatch any buffered renders we accumulated during a disconnect.
@@ -188,7 +152,6 @@ public async Task DispatchEvent(string eventDescriptorJson, string eventArgs)
188
152
return ;
189
153
}
190
154
191
-
192
155
await Renderer . Dispatcher . InvokeAsync ( ( ) =>
193
156
{
194
157
SetCurrentCircuitHost ( this ) ;
@@ -233,13 +196,11 @@ await Renderer.Dispatcher.InvokeAsync(async () =>
233
196
// That's because AddComponentAsync waits for quiescence, which can take
234
197
// arbitrarily long. In the meantime we might need to be receiving and
235
198
// processing incoming JSInterop calls or similar.
236
- for ( var i = 0 ; i < Descriptors . Count ; i ++ )
199
+ var count = Descriptors . Count ;
200
+ for ( var i = 0 ; i < count ; i ++ )
237
201
{
238
- var ( componentType , domElementSelector , prerendered ) = Descriptors [ i ] ;
239
- if ( ! prerendered )
240
- {
241
- await Renderer . AddComponentAsync ( componentType , domElementSelector ) ;
242
- }
202
+ var ( componentType , domElementSelector ) = Descriptors [ i ] ;
203
+ await Renderer . AddComponentAsync ( componentType , domElementSelector ) ;
243
204
}
244
205
}
245
206
catch ( Exception ex )
@@ -256,7 +217,7 @@ public async Task BeginInvokeDotNetFromJS(string callId, string assemblyName, st
256
217
try
257
218
{
258
219
AssertInitialized ( ) ;
259
- if ( assemblyName == "Microsoft.AspNetCore.Components.Web" && methodIdentifier == "DispatchEvent" )
220
+ if ( assemblyName == "Microsoft.AspNetCore.Components.Web" && methodIdentifier == "DispatchEvent" )
260
221
{
261
222
Log . DispatchEventTroughJSInterop ( _logger ) ;
262
223
return ;
0 commit comments