Class CollectionWithIdsSerializerBase
A base class to serialize collections with unique identifiers for each item.
[YamlSerializerFactory(new string[] { "Assets" })]
public abstract class CollectionWithIdsSerializerBase : DictionarySerializer, IYamlSerializable, IYamlSerializableFactory- Inheritance
- 
      objectObjectSerializerDictionarySerializerCollectionWithIdsSerializerBase
- Implements
- 
      IYamlSerializableIYamlSerializableFactory
- Derived
- Inherited Members
- 
    DictionarySerializer.TryCreate(SerializerContext, ITypeDescriptor)DictionarySerializer.ReadMember(ref ObjectContext)DictionarySerializer.WriteMembers(ref ObjectContext)ObjectSerializer.GetStyle(ref ObjectContext)ObjectSerializer.TransformObjectAfterRead(ref ObjectContext)ObjectSerializer.ReadMembers<TStart, TEnd>(ref ObjectContext)ObjectSerializer.WriteMember(ref ObjectContext, IMemberDescriptor)
Fields
DeletedItemsKey
A key that identifies deleted items during deserialization.
protected static readonly PropertyKey<ICollection<ItemId>> DeletedItemsKeyField Value
InstanceInfoKey
A key that identifies the information about the instance that we need the store in the Stride.Core.Yaml.Serialization.ObjectContext.Properties dictionary.
protected static readonly PropertyKey<CollectionWithIdsSerializerBase.InstanceInfo> InstanceInfoKeyField Value
NonIdentifiableCollectionItemsKey
A property key to indicate whether a collection has non-identifiable items
public static readonly PropertyKey<bool> NonIdentifiableCollectionItemsKeyField Value
YamlDeletedKey
A string token to identify deleted items in a collection.
public const string YamlDeletedKey = "~(Deleted)"Field Value
Methods
AreCollectionItemsIdentifiable(ref ObjectContext)
protected static bool AreCollectionItemsIdentifiable(ref ObjectContext objectContext)Parameters
- objectContextObjectContext
Returns
CheckIsSequence(ref ObjectContext)
Checks if a type is a sequence.
protected override bool CheckIsSequence(ref ObjectContext objectContext)Parameters
- objectContextObjectContext
Returns
- bool
- trueif a type is a sequence,- falseotherwise.
CreatEmptyContainer(ITypeDescriptor)
Creates an empty dictionary that can store the mapping of ids to items of the collection.
protected abstract IDictionary CreatEmptyContainer(ITypeDescriptor descriptor)Parameters
- descriptorITypeDescriptor
- The type descriptor of the collection for which to create the dictionary. 
Returns
- IDictionary
- An empty dictionary for mapping ids to elements. 
CreateOrTransformObject(ref ObjectContext)
Overrides this method when deserializing/serializing an object that needs a special instantiation or transformation. By default, this is calling Create(Type) if the Stride.Core.Yaml.Serialization.ObjectContext.Instance is null or returning Stride.Core.Yaml.Serialization.ObjectContext.Instance.
protected override void CreateOrTransformObject(ref ObjectContext objectContext)Parameters
- objectContextObjectContext
- The object context. 
ReadDeletedDictionaryItem(ref ObjectContext, object)
protected abstract KeyValuePair<object, object> ReadDeletedDictionaryItem(ref ObjectContext objectContext, object keyResult)Parameters
- objectContextObjectContext
- keyResultobject
Returns
- KeyValuePair<object, object>
ReadDictionaryItem(ref ObjectContext, KeyValuePair<Type, Type>)
Reads a dictionary item key-value.
protected override KeyValuePair<object, object> ReadDictionaryItem(ref ObjectContext objectContext, KeyValuePair<Type, Type> keyValueTypes)Parameters
- objectContextObjectContext
- The object context. 
- keyValueTypesKeyValuePair<Type, Type>
- The types corresponding to the key and the value. 
Returns
- KeyValuePair<object, object>
- A KeyValuePair<TKey, TValue> representing the dictionary item. 
ReadDictionaryItems(ref ObjectContext)
Reads the dictionary items key-values.
protected override void ReadDictionaryItems(ref ObjectContext objectContext)Parameters
- objectContextObjectContext
ReadYaml(ref ObjectContext)
Reads this object's state from a YAML parser.
public override object ReadYaml(ref ObjectContext objectContext)Parameters
- objectContextObjectContext
Returns
- object
- A instance of the object deserialized from Yaml. 
ReadYamlAfterTransform(ref ObjectContext, bool)
protected virtual void ReadYamlAfterTransform(ref ObjectContext objectContext, bool transformed)Parameters
- objectContextObjectContext
- transformedbool
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 abstract void TransformAfterDeserialization(IDictionary container, ITypeDescriptor targetDescriptor, object targetCollection, ICollection<ItemId>? deletedItems = null)Parameters
- containerIDictionary
- The dictionary mapping ids to item. 
- targetDescriptorITypeDescriptor
- The type descriptor of the actual collection to fill. 
- targetCollectionobject
- The instance of the actual collection to fill. 
- deletedItemsICollection<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 abstract object TransformForSerialization(ITypeDescriptor descriptor, object collection)Parameters
- descriptorITypeDescriptor
- The type descriptor of the collection. 
- collectionobject
- The collection for which to create the mapping dictionary. 
Returns
- object
- A dictionary mapping the id to the element of the initial collection. 
WriteDeletedItems(ref ObjectContext)
protected abstract void WriteDeletedItems(ref ObjectContext objectContext)Parameters
- objectContextObjectContext
WriteDictionaryItems(ref ObjectContext)
Writes the dictionary items keys-values.
protected override void WriteDictionaryItems(ref ObjectContext objectContext)Parameters
- objectContextObjectContext
- The object context. 
WriteYaml(ref ObjectContext)
Writes the specified object context to a YAML emitter.
public override void WriteYaml(ref ObjectContext objectContext)Parameters
- objectContextObjectContext
- The object context. 
WriteYamlAfterTransform(ref ObjectContext, bool)
protected virtual void WriteYamlAfterTransform(ref ObjectContext objectContext, bool transformed)Parameters
- objectContextObjectContext
- transformedbool