Example #1
0
        private ServerComponentMarker[] CreateMarkers(ServerComponentInvocationSequence sequence, params Type[] types)
        {
            var serializer = new ServerComponentSerializer(_ephemeralDataProtectionProvider);
            var markers    = new ServerComponentMarker[types.Length];

            for (var i = 0; i < types.Length; i++)
            {
                markers[i] = serializer.SerializeInvocation(sequence, types[i], false);
            }

            return(markers);
        }
Example #2
0
    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));
    }
Example #3
0
 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));
 }