@@ -16,17 +16,24 @@ public ServerComponentSerializer(IDataProtectionProvider dataProtectionProvider)
1616 . CreateProtector ( ServerComponentSerializationSettings . DataProtectionProviderPurpose )
1717 . ToTimeLimitedDataProtector ( ) ;
1818
19- public void SerializeInvocation ( ref ComponentMarker marker , ServerComponentInvocationSequence invocationId , Type type , ParameterView parameters )
19+ public void SerializeInvocation (
20+ ref ComponentMarker marker ,
21+ ServerComponentInvocationSequence invocationId ,
22+ Type type ,
23+ ParameterView parameters ,
24+ TimeSpan ? dataExpiration = default )
2025 {
21- var ( sequence , serverComponent ) = CreateSerializedServerComponent ( invocationId , type , parameters , marker . Key ) ;
26+ var expiration = dataExpiration ?? ServerComponentSerializationSettings . DataExpiration ;
27+ var ( sequence , serverComponent ) = CreateSerializedServerComponent ( invocationId , type , parameters , marker . Key , expiration ) ;
2228 marker . WriteServerData ( sequence , serverComponent ) ;
2329 }
2430
2531 private ( int sequence , string payload ) CreateSerializedServerComponent (
2632 ServerComponentInvocationSequence invocationId ,
2733 Type rootComponent ,
2834 ParameterView parameters ,
29- ComponentMarkerKey ? key )
35+ ComponentMarkerKey ? key ,
36+ TimeSpan dataExpiration )
3037 {
3138 var sequence = invocationId . Next ( ) ;
3239
@@ -42,7 +49,7 @@ public void SerializeInvocation(ref ComponentMarker marker, ServerComponentInvoc
4249 invocationId . Value ) ;
4350
4451 var serializedServerComponentBytes = JsonSerializer . SerializeToUtf8Bytes ( serverComponent , ServerComponentSerializationSettings . JsonSerializationOptions ) ;
45- var protectedBytes = _dataProtector . Protect ( serializedServerComponentBytes , ServerComponentSerializationSettings . DataExpiration ) ;
52+ var protectedBytes = _dataProtector . Protect ( serializedServerComponentBytes , dataExpiration ) ;
4653 return ( serverComponent . Sequence , Convert . ToBase64String ( protectedBytes ) ) ;
4754 }
4855}
0 commit comments