Table of Contents

Class CollectionWithIdsSerializer

Namespace
Stride.Core.Yaml
Assembly
Stride.Core.Assets.dll

An implementation of CollectionWithIdsSerializerBase for actual collections.

[YamlSerializerFactory(new string[] { "Assets" })]
public class CollectionWithIdsSerializer : CollectionWithIdsSerializerBase, IYamlSerializable, IYamlSerializableFactory
Inheritance
ObjectSerializer
DictionarySerializer
CollectionWithIdsSerializer
Implements
IYamlSerializable
IYamlSerializableFactory
Inherited Members
DictionarySerializer.ReadMember(ref ObjectContext)
DictionarySerializer.WriteMembers(ref ObjectContext)
ObjectSerializer.GetStyle(ref ObjectContext)
ObjectSerializer.ReadMembers<TStart, TEnd>(ref ObjectContext)
ObjectSerializer.WriteMember(ref ObjectContext, IMemberDescriptor)

Methods

CreatEmptyContainer(ITypeDescriptor)

Creates an empty dictionary that can store the mapping of ids to items of the collection.

protected override IDictionary CreatEmptyContainer(ITypeDescriptor descriptor)

Parameters

descriptor ITypeDescriptor

The type descriptor of the collection for which to create the dictionary.

Returns

IDictionary

An empty dictionary for mapping ids to elements.

GetCollectionSerializerForNonTransformedObject()

protected virtual CollectionSerializer GetCollectionSerializerForNonTransformedObject()

Returns

CollectionSerializer

ReadDeletedDictionaryItem(ref ObjectContext, object)

protected override KeyValuePair<object, object> ReadDeletedDictionaryItem(ref ObjectContext objectContext, object keyResult)

Parameters

objectContext ObjectContext
keyResult object

Returns

KeyValuePair<object, object>

ReadYamlAfterTransform(ref ObjectContext, bool)

protected override void ReadYamlAfterTransform(ref ObjectContext objectContext, bool transformed)

Parameters

objectContext ObjectContext
transformed bool

TransformAfterDeserialization(IDictionary, ITypeDescriptor, object, ICollection<ItemId>)

Transforms a dictionary containing the mapping of ids to items into the actual collection, and store the ids in the Stride.Core.Reflection.ShadowObject.

protected override void TransformAfterDeserialization(IDictionary container, ITypeDescriptor targetDescriptor, object targetCollection, ICollection<ItemId> deletedItems = null)

Parameters

container IDictionary

The dictionary mapping ids to item.

targetDescriptor ITypeDescriptor

The type descriptor of the actual collection to fill.

targetCollection object

The instance of the actual collection to fill.

deletedItems ICollection<ItemId>

A collection of items that are marked as deleted. Can be null.

TransformForSerialization(ITypeDescriptor, object)

Transforms the given collection or dictionary into a dictionary of (ids, items) or a dictionary of (ids & keys, items).

protected override object TransformForSerialization(ITypeDescriptor descriptor, object collection)

Parameters

descriptor ITypeDescriptor

The type descriptor of the collection.

collection object

The collection for which to create the mapping dictionary.

Returns

object

A dictionary mapping the id to the element of the initial collection.

TransformObjectAfterRead(ref ObjectContext)

Transforms the object after it has been read. This method is called after an object has been read and before returning the object to the deserialization process. See remarks for usage.

protected override void TransformObjectAfterRead(ref ObjectContext objectContext)

Parameters

objectContext ObjectContext

Remarks

This method is usefull in conjunction with Stride.Core.Yaml.Serialization.Serializers.ObjectSerializer.CreateOrTransformObject(ref Stride.Core.Yaml.Serialization.ObjectContext). For example, in the case of deserializing to an immutable member, where we need to call the constructor of a type instead of setting each of its member, we can instantiate a mutable object in Stride.Core.Yaml.Serialization.Serializers.ObjectSerializer.CreateOrTransformObject(ref Stride.Core.Yaml.Serialization.ObjectContext), receive the mutable object filled in Stride.Core.Yaml.Serialization.Serializers.ObjectSerializer.TransformObjectAfterRead(ref Stride.Core.Yaml.Serialization.ObjectContext) and transform it back to an immutable object.

TryCreate(SerializerContext, ITypeDescriptor)

Try to create a Stride.Core.Yaml.Serialization.IYamlSerializable or return null if not supported for a particular .NET typeDescriptor.

public override IYamlSerializable TryCreate(SerializerContext context, ITypeDescriptor typeDescriptor)

Parameters

context SerializerContext
typeDescriptor ITypeDescriptor

The typeDescriptor.

Returns

IYamlSerializable

If supported, return an instance of Stride.Core.Yaml.Serialization.IYamlSerializable else return null.

WriteDeletedItems(ref ObjectContext)

protected override void WriteDeletedItems(ref ObjectContext objectContext)

Parameters

objectContext ObjectContext

WriteYamlAfterTransform(ref ObjectContext, bool)

protected override void WriteYamlAfterTransform(ref ObjectContext objectContext, bool transformed)

Parameters

objectContext ObjectContext
transformed bool