Context for serializing ron elements.
Custom overrides for Ron are stored in the local or global serialization context.
parentContext: The parent context. Null for the root context.
Context for serializing ron elements.
Custom overrides for Ron are stored in the local or global serialization context.
parentContext: The parent context. Null for the root context.
HashSet<Type> RonTypes
Set of types recognized by this serialization context.
Dictionary<Type Type> proxyTypes
Proxy types recognized by this serialization context.
The parent serialization context to inherit.
SerializationResult<object> DeserializeElement (RonElement? element,Type? typeHint,string path)
Deserialize a ron element.
element: The element to deserialize.
typeHint: The type hint to deserialize the object to.
path: The path of the element being deserialized.
returns: The C# object deserialized.
SerializationResult<object> DeserializeUnitClass (Type typeHint,RonUnitStruct unitStruct)
Deserialize Unit Tuple.
typeHint: The type hint to deserialize the object to.
unitStruct: The RonUnitStruct to deserialize.
returns: A serialization result with the object.
SerializationResult<object> DeserializeEnum (Type enumType,RonElement identifier)
Deserialize Enum.
enumType: The type of the enum.
identifier: The identifier.
returns: A serialization result with the enum.
SerializationResult<object> DeserializeNamedValueClass (Type? typeHint,RonNamedValueStruct element,string path)
Deserialize name value struct.
typeHint: The type hint to deserialize the object to.
element: The element to deserialize.
path: The path of the element.
returns:
SerializationResult<object> DeserializeClassField (RonElement element,object instance,string path)
Deserialize named field.
element:
instance:
path:
returns:
SerializationResult<object> DeserializeTupleStructClass (Type? typeHint,RonTupleStruct element,string path)
Deserialize Tuple struct
typeHint:
element:
path:
returns:
SerializationResult<object> DeserializeTupleClassBody (Type typeHint,RonTuple body,string path)
Deserialize ron tuple class body.
typeHint:
body:
path:
returns:
SerializationResult<object> DeserializeList (Type? typeHint,RonList list,string path)
Deserialize list
typeHint:
list:
path:
returns:
SerializationResult<object> DeserializeMap (RonMap map,Type? typeHint,string path)
Deserialize map
map:
typeHint:
path:
returns:
throw:
Type
ResolveTypeName
(string? name,Type? backupType)
Get a type from it's name.
name: The name of the type.
backupType: The backup type to use if resolution fails.
returns: The type to use for deserialization if it can be resolved. Null otherwise.
Type
ResolveIntermediateType
(Type? targetType)
Get intermediate deserialization type, such as for a proxy.
targetType: The target type to deserialize to.
returns: The intermediate type to use for deserialization.
Type
InferType
(RonElement? element)
Infer the type of the AST element.
If the type cannot be inferred then return null.
element: The element to infer the type of.
returns: The type if it can be inferred.
Type
GetMapIntermediateType
(Type? type)
Get the value type for deserializing a ron map.
type: The map type.
returns: The value type of the map.
object
ConvertType
(object? source,Type? targetType)
Convert type from the source to the targetType.
source: The source object.
targetType: The target type.
returns: The converted object.
Create global serialization context.
returns: The global serialization context.
Memoized converters to use.
RonElement
ToAST
(object? source,Type? fieldType = null)
Convert the object to a Ron AST.
If field type is provided it will allow for inference for the element.
source: The source object to convert to an AST element.
fieldType: The type of the field being serialized, if relevant.
returns:
static
RonInteger
CreateIntValue
(object source,IntegerSuffix? suffix)
Create a Ron integer element.
source:
suffix:
returns:
static
RonFloat
CreateFloatValue
(object source,FloatSuffix? suffix)
Create a Ron float element.
source:
suffix:
returns:
static
string
ShortestRound
(object source)
Determine the shortest round trippable string.
source:
returns:
void
RegisterType
(Type type)
Register a new known type
type: The type to register.
void
RegisterTypeConverter
(Type type,TypeSerializerConverter converter)
Register a custom type converter for the type.
type: The type to use this converter for.
converter: The converter to use.
void
RegisterListType
(Type type)
Register type to be serialized as a list.
type: The type to serialize/deserialize as a list.
void
RegisterMapType
(Type type)
Register type to be serialized as a map.
type: The type to serialize/deserialize as a map.
void
RegisterTupleConverter<Target> (Func<Target object[]> converter)
Register converter to serialize a type as a tuple.
Target The target type to serialize as a tuple.
converter: The converter to use to serialize the element as a tuple.
void
RegisterProxyType
(Type sourceType,Type proxyType)
Register a custom proxy for the source type.
sourceType: The source type for the proxy.
proxyType: The proxy type to use for serialization/deserialization.