/// <summary> /// Serializes a generic list to a stream. /// </summary> /// <param name="archive">Archive to put the specified list into.</param> /// <param name="version">Serializer version to use.</param> /// <param name="obj">List to serialize.</param> /// <exception cref="VersionNotSupportedException">Serializer version is not supported.</exception> public void Serialize(SerializerArchive archive, uint version, object obj) { if (version == 1) { IList list = (IList)obj; int count = list.Count; archive.Write(count); for (int i = 0; i < count; i++) { archive.Write(list[i], archive.Context); } } else { throw new VersionNotSupportedException(typeof(List <>), version); } }
/// <summary> /// Serializes a GUID to a stream. /// </summary> /// <param name="archive">Archive to put the specfied GUID into.</param> /// <param name="version">Requested version when serializing the GUID.</param> /// <param name="obj">Object to serialize (type System.Guid).</param> /// <exception cref="VersionNotSupportedException">Serializer version is not supported.</exception> public void Serialize(SerializerArchive archive, uint version, object obj) { if (version == 1) { Guid guid = (Guid)obj; archive.Write(guid.ToUuidByteArray()); } else { throw new VersionNotSupportedException(typeof(Guid), version); } }