Version 3.3.1.2

FormatterLocator class

Namespace: Sirenix.Serialization
Assembly: Sirenix.Serialization
public static class FormatterLocator
Utility class for locating and caching formatters for all non-primitive types.
Inheritance
  • System.Object
  • FormatterLocator

Methods

GetFormatter(Type, ISerializationPolicy)
Gets a formatter for a given type.
public static IFormatter GetFormatter(Type type, ISerializationPolicy policy)
Parameters
System.Type type

The type to get a formatter for.

Sirenix.Serialization.ISerializationPolicy policy

The serialization policy to use if a formatter has to be emitted. If null, Strict is used.

Returns
Sirenix.Serialization.IFormatter

A formatter for the given type.

Exceptions
System.ArgumentNullException

The type argument is null.

GetFormatter(Type, ISerializationPolicy, Boolean)
Gets a formatter for a given type.
public static IFormatter GetFormatter(Type type, ISerializationPolicy policy, bool allowWeakFallbackFormatters)
Parameters
System.Type type

The type to get a formatter for.

Sirenix.Serialization.ISerializationPolicy policy

The serialization policy to use if a formatter has to be emitted. If null, Strict is used.

System.Boolean allowWeakFallbackFormatters

Whether to allow the use of weak fallback formatters which do not implement the strongly typed Sirenix.Serialization.IFormatter<T>, but which conversely do not need to have had AOT support generated.

Returns
Sirenix.Serialization.IFormatter

A formatter for the given type.

Exceptions
System.ArgumentNullException

The type argument is null.

GetFormatter<T>(ISerializationPolicy)
Gets a formatter for the type .
public static IFormatter<T> GetFormatter<T>(ISerializationPolicy policy)
Parameters
Sirenix.Serialization.ISerializationPolicy policy

The serialization policy to use if a formatter has to be emitted. If null, Strict is used.

Returns
Sirenix.Serialization.IFormatter<T>

A formatter for the type .

Type Parameters
T

The type to get a formatter for.

Events

OnLocatedEmittableFormatterForType
Editor-only event that fires whenever an emittable formatter has been located. This event is used by the AOT formatter pre-emitter to locate types that need to have formatters pre-emitted.
public static event Action<Type> OnLocatedEmittableFormatterForType
OnLocatedFormatter
Editor-only event that fires whenever a formatter has been located.
public static event Action<IFormatter> OnLocatedFormatter