Version 3.3.0.1

SerializationContext class

Namespace: Sirenix.Serialization
Assembly: Sirenix.Serialization
public sealed class SerializationContext : ICacheNotificationReceiver
The context of a given serialization session. This class maintains all internal and external references during serialization.
Inheritance
  • System.Object
  • SerializationContext
See Also
  • Sirenix.Serialization.Utilities.ICacheNotificationReceiver

Constructors

SerializationContext()
Initializes a new instance of the SerializationContext class.
public SerializationContext()
SerializationContext(FormatterConverter)
Initializes a new instance of the SerializationContext class.
public SerializationContext(FormatterConverter formatterConverter)
Parameters
System.Runtime.Serialization.FormatterConverter formatterConverter

The formatter converter to use.

SerializationContext(StreamingContext)
Initializes a new instance of the SerializationContext class.
public SerializationContext(StreamingContext context)
Parameters
System.Runtime.Serialization.StreamingContext context

The streaming context to use.

SerializationContext(StreamingContext, FormatterConverter)
Initializes a new instance of the SerializationContext class.
public SerializationContext(StreamingContext context, FormatterConverter formatterConverter)
Parameters
System.Runtime.Serialization.StreamingContext context

The streaming context to use.

System.Runtime.Serialization.FormatterConverter formatterConverter

The formatter converter to use.

Exceptions
System.ArgumentNullException

The formatterConverter parameter is null.

Properties

Binder
Gets or sets the context's type binder.
public TwoWaySerializationBinder Binder { get; set; }
Config
Gets or sets the serialization configuration.
public SerializationConfig Config { get; set; }
FormatterConverter
Gets the formatter converter.
public IFormatterConverter FormatterConverter { get; }
GuidReferenceResolver
Gets or sets the Guid reference resolver.
public IExternalGuidReferenceResolver GuidReferenceResolver { get; set; }
IndexReferenceResolver
Gets or sets the index reference resolver.
public IExternalIndexReferenceResolver IndexReferenceResolver { get; set; }
StreamingContext
Gets the streaming context.
public StreamingContext StreamingContext { get; }
StringReferenceResolver
Gets or sets the string reference resolver.
public IExternalStringReferenceResolver StringReferenceResolver { get; set; }

Methods

ResetInternalReferences()
Resets the context's internal reference map.
public void ResetInternalReferences()
ResetToDefault()
Resets the serialization context completely to baseline status, as if its constructor has just been called. This allows complete reuse of a serialization context, with all of its internal reference buffers.
public void ResetToDefault()
TryGetInternalReferenceId(Object, out Int32)
Tries to get the id of an internally referenced object.
public bool TryGetInternalReferenceId(object reference, out int id)
Parameters
System.Object reference

The reference to get the id of.

System.Int32 id

The id that was found, or -1 if no id was found.

Returns
System.Boolean

true if a reference was found, otherwise false.

TryRegisterExternalReference(Object, out Guid)
Tries to register an external guid reference.
public bool TryRegisterExternalReference(object obj, out Guid guid)
Parameters
System.Object obj

The object to reference.

System.Guid guid

The guid of the referenced object.

Returns
System.Boolean

true if the object could be referenced by guid; otherwise, false.

TryRegisterExternalReference(Object, out Int32)
Tries to register an external index reference.
public bool TryRegisterExternalReference(object obj, out int index)
Parameters
System.Object obj

The object to reference.

System.Int32 index

The index of the referenced object.

Returns
System.Boolean

true if the object could be referenced by index; otherwise, false.

TryRegisterExternalReference(Object, out String)
Tries to register an external string reference.
public bool TryRegisterExternalReference(object obj, out string id)
Parameters
System.Object obj

The object to reference.

System.String id

The id string of the referenced object.

Returns
System.Boolean

true if the object could be referenced by string; otherwise, false.

TryRegisterInternalReference(Object, out Int32)
Tries to register an internal reference. Returns true if the reference was registered, otherwise, false when the reference has already been registered.
public bool TryRegisterInternalReference(object reference, out int id)
Parameters
System.Object reference

The reference to register.

System.Int32 id

The id of the registered reference.

Returns
System.Boolean

true if the reference was registered, otherwise, false when the reference has already been registered.