NameInvariantSurrogateSelector Class

Note: This API is now obsolete.
An ISurrogateSelector implementation that makes possible to serialize and deserialize objects by IFormatters without storing field names. This provides compatibility for obfuscated and non-obfuscated versions of an assembly.

Definition

Namespace: KGySoft.Serialization.Binary
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 9.0.0
C#
[ObsoleteAttribute("It's not recommended to use this class. If you need to make different kinds of builds of an assembly binary serialization-compatible, then it is a sign that binary serialization is used in an insecure way.")]
public class NameInvariantSurrogateSelector : ISurrogateSelector, 
	ISerializationSurrogate
Inheritance
Object    NameInvariantSurrogateSelector
Implements
ISerializationSurrogate, ISurrogateSelector

Remarks

  Security Note

If you deserialize a stream from an untrusted source make sure that you set the SafeMode property, which prevents supporting non-serializable types. Please note though that you cannot use this class for BinarySerializationFormatter when the SafeMode flag is enabled in its Options property, even if the SafeMode property is set to .

See also the security notes at the Remarks section of the BinarySerializationFormatter class for more details.

You can use this surrogate selector for any non-primitive types that do not implement ISerializable interface.

  Note

Versioning by this surrogate selector can be accomplished only if new fields are always defined after the old ones on every level of the hierarchy. You might want to use also the WeakAssemblySerializationBinder class to ignore version information of assemblies on deserialization.

  Caution

Please note that this surrogate selector does not identify field names on deserialization so reordering members may corrupt or fail deserialization.

Constructors

NameInvariantSurrogateSelectorInitializes a new instance of the NameInvariantSurrogateSelector class

Properties

SafeMode Gets or sets whether it is prohibited to serialize and deserialize types that are not marked by SerializableAttribute.
Default value: .

Methods

ChainSelector Specifies the next ISurrogateSelector for surrogates to examine if the current instance does not have a surrogate for the specified type and assembly in the specified context.
GetNextSelector Returns the next surrogate selector in the chain.
GetSurrogate Finds the surrogate that represents the specified object's type, starting with the specified surrogate selector for the specified serialization context.

Extension Methods

Convert Converts an Object specified in the obj parameter to the desired targetType.
See the Examples section of the generic ConvertTTarget(Object, CultureInfo) overload for an example.
(Defined by ObjectExtensions)
ConvertTTarget Converts an Object specified in the obj parameter to the desired TTarget.
(Defined by ObjectExtensions)
In Gets whether item is among the elements of set.
See the Examples section of the generic InT(T, T) overload for an example.
(Defined by ObjectExtensions)
TryConvert Tries to convert an Object specified in the obj parameter to the desired targetType.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example.
(Defined by ObjectExtensions)
TryConvert Tries to convert an Object specified in the obj parameter to the desired targetType.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example.
(Defined by ObjectExtensions)
TryConvertTTarget Tries to convert an Object specified in the obj parameter to the desired TTarget.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example.
(Defined by ObjectExtensions)
TryConvertTTarget Tries to convert an Object specified in the obj parameter to the desired TTarget.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example.
(Defined by ObjectExtensions)

See Also