private void InitializeRegisteredRootComponents(WebAssemblyJSRuntimeInvoker jsRuntimeInvoker) { var componentsCount = jsRuntimeInvoker.InvokeUnmarshalled <object, object, object, int>(RegisteredComponentsInterop.GetRegisteredComponentsCount, null, null, null); if (componentsCount == 0) { return; } var registeredComponents = new WebAssemblyComponentMarker[componentsCount]; for (var i = 0; i < componentsCount; i++) { var id = jsRuntimeInvoker.InvokeUnmarshalled <int, object, object, int>(RegisteredComponentsInterop.GetId, i, null, null); var assembly = jsRuntimeInvoker.InvokeUnmarshalled <int, object, object, string>(RegisteredComponentsInterop.GetAssembly, id, null, null); var typeName = jsRuntimeInvoker.InvokeUnmarshalled <int, object, object, string>(RegisteredComponentsInterop.GetTypeName, id, null, null); var serializedParameterDefinitions = jsRuntimeInvoker.InvokeUnmarshalled <int, object, object, string>(RegisteredComponentsInterop.GetParameterDefinitions, id, null, null); var serializedParameterValues = jsRuntimeInvoker.InvokeUnmarshalled <int, object, object, string>(RegisteredComponentsInterop.GetParameterValues, id, null, null); registeredComponents[i] = new WebAssemblyComponentMarker(WebAssemblyComponentMarker.ClientMarkerType, assembly, typeName, serializedParameterDefinitions, serializedParameterValues, id.ToString()); } var componentDeserializer = WebAssemblyComponentParameterDeserializer.Instance; foreach (var registeredComponent in registeredComponents) { _rootComponentCache = new RootComponentTypeCache(); var componentType = _rootComponentCache.GetRootComponent(registeredComponent.Assembly, registeredComponent.TypeName); var definitions = componentDeserializer.GetParameterDefinitions(registeredComponent.ParameterDefinitions); var values = componentDeserializer.GetParameterValues(registeredComponent.ParameterValues); var parameters = componentDeserializer.DeserializeParameters(definitions, values); RootComponents.Add(componentType, registeredComponent.PrerenderId, parameters); } }
public ServerComponentDeserializer( IDataProtectionProvider dataProtectionProvider, ILogger <ServerComponentDeserializer> logger, RootComponentTypeCache rootComponentTypeCache, ComponentParameterDeserializer parametersDeserializer) { // When we protect the data we use a time-limited data protector with the // limits established in 'ServerComponentSerializationSettings.DataExpiration' // We don't use any of the additional methods provided by ITimeLimitedDataProtector // in this class, but we need to create one for the unprotect operations to work // even though we simply call '_dataProtector.Unprotect'. // See the comment in ServerComponentSerializationSettings.DataExpiration to understand // why we limit the validity of the protected payloads. _dataProtector = dataProtectionProvider .CreateProtector(ServerComponentSerializationSettings.DataProtectionProviderPurpose) .ToTimeLimitedDataProtector(); _logger = logger; _rootComponentTypeCache = rootComponentTypeCache; _parametersDeserializer = parametersDeserializer; }