IReliableStateManager.TryAddStateSerializer<T> Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Registers a custom serializer for all reliable collections.
public bool TryAddStateSerializer<T> (Microsoft.ServiceFabric.Data.IStateSerializer<T> stateSerializer);
abstract member TryAddStateSerializer : Microsoft.ServiceFabric.Data.IStateSerializer<'T> -> bool
Public Function TryAddStateSerializer(Of T) (stateSerializer As IStateSerializer(Of T)) As Boolean
Type Parameters
- T
Type that will be serialized and deserialized.
Parameters
- stateSerializer
- IStateSerializer<T>
The state serializer to be added.
Returns
True if the custom serializer was added. False if a custom serializer for the given type already exists.
Remarks
When a reliable collection needs to serialize an object, it asks the state manager for a serializer for the given type. The state manager will first check if there is a custom serializer registered for the input type. If not, it will check if one of the built-in serializers can serialize the type. The state manager has built-in serializers for the following types: guid, bool, byte, sbyte, char, decimal, double, float, int, uint, long, ulong, short, ushort and string. If not, it will use DataContractSerializer.
Serializers must be infinitely forwards and backwards compatible. For the types that are using built-in serializers, Service Fabric ensures forwards and backwards compatibility. However, if a custom serializer is added for a type with a built-in serializer, the custom serializer must be compatible with the built-in serialization format for that type.
This method should be called from the constructor of the Stateful Service. This ensures that the Reliable Collections have the necessary serializers before recovery of the persisted state begins.
Applies to
Azure SDK for .NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기