Class ConverterFactory<T>
- Namespace
- Dec
- Assembly
- dec.dll
Base class for converting to arbitrary types via the Recorder API, with full control over the object creation process.
public abstract class ConverterFactory<T> : ConverterFactory
Type Parameters
T
- Inheritance
-
objectConverterConverterFactoryConverterFactory<T>
Remarks
This is a standalone class to allow implementation of converters of third-party types. It's useful when implementing converters for types that were not created by you (ex: UnityEngine.Vector).
ConverterFactory is suitable for converting to and from objects constructed in whatever way you wish, possibly with custom constructors or provided via your framework. It allows you to reference other objects and build arbitrarily complicated hierarchies.
This is the most complicated Converter to work with, but also the most powerful. This should be your last choice of Converter, used only if neither ConverterString nor ConverterRecord are appropriate. Empirically, this appears to be rarely used . . . but it's available when needed.
Methods
Create(Recorder)
Creates an object.
public abstract T Create(Recorder recorder)
Parameters
recorder
Recorder
Returns
- T
Remarks
This is similar to Dec.IRecordable.Record
, although you'll need to use this
instead of input
.
This function will not be called if an instance already exists. In addition, you cannot reference other shared objects within Create, even transitively. Those must be referenced within Read. It is recommended that you do the bare minimum here to create the necessary object.
Read(ref T, Recorder)
Reads an object.
public abstract void Read(ref T input, Recorder recorder)
Parameters
input
Trecorder
Recorder
Remarks
This is similar to Dec.IRecordable.Record
, although you'll need to use this
instead of input
.
Write(T, Recorder)
Writes an object.
public abstract void Write(T input, Recorder recorder)
Parameters
input
Trecorder
Recorder
Remarks
See Dec.IRecordable.Record
for details, although you'll need to use this
instead of input
.