Class ConverterString<T>
- Namespace
- Dec
- Assembly
- dec.dll
Base class for converting to arbitrary types via strings.
public abstract class ConverterString<T> : ConverterString
Type Parameters
T
- Inheritance
-
objectConverterConverterStringConverterString<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.Mesh).
ConverterString is suitable only for converting to and from independent simple string objects. It does not let you reference other objects within the Recorder hierarchy (see ConverterRecord and ConverterFactory), nor does it allow you to respect default settings pre-provided by an object's constructor, nor does it allow you to build complex hierarchies appropriate for complex objects.
It does allow you to create your own objects as you see fit, or reference objects provided by your framework that have no useful default constructor.
This should likely be your first choice of Converter if reasonably suitable, although if string serialization is complicated, use ConverterRecord instead even if you don't technically have to.
Methods
Read(string, Context)
Converts a string to a suitable object type.
public abstract T Read(string input, Context context)
Parameters
Returns
- T
Remarks
In case of error, call Dec.Dbg.Err with some appropriately useful message and return default. Message should be formatted as $"{context}: Something went wrong".
Write(T)
Converts an object to a string.
public abstract string Write(T input)
Parameters
input
T