private (int sequence, string payload) CreateSerializedServerComponent( ServerComponentInvocationSequence invocationId, Type rootComponent) { var sequence = invocationId.Next(); var serverComponent = new ServerComponent( sequence, rootComponent.Assembly.GetName().Name, rootComponent.FullName, invocationId.Value); var serializedServerComponent = JsonSerializer.Serialize(serverComponent, ServerComponentSerializationSettings.JsonSerializationOptions); return(serverComponent.Sequence, _dataProtector.Protect(serializedServerComponent, ServerComponentSerializationSettings.DataExpiration)); }
private (int sequence, string payload) CreateSerializedServerComponent( ServerComponentInvocationSequence invocationId, Type rootComponent, ParameterView parameters) { var sequence = invocationId.Next(); var(definitions, values) = ComponentParameter.FromParameterView(parameters); var serverComponent = new ServerComponent( sequence, rootComponent.Assembly.GetName().Name, rootComponent.FullName, definitions, values, invocationId.Value); var serializedServerComponentBytes = JsonSerializer.SerializeToUtf8Bytes(serverComponent, ServerComponentSerializationSettings.JsonSerializationOptions); var protectedBytes = _dataProtector.Protect(serializedServerComponentBytes, ServerComponentSerializationSettings.DataExpiration); return(serverComponent.Sequence, Convert.ToBase64String(protectedBytes)); }
public ServerComponentMarker SerializeInvocation(ServerComponentInvocationSequence invocationId, Type type, ParameterView parameters, bool prerendered) { var(sequence, serverComponent) = CreateSerializedServerComponent(invocationId, type, parameters); return(prerendered ? ServerComponentMarker.Prerendered(sequence, serverComponent) : ServerComponentMarker.NonPrerendered(sequence, serverComponent)); }