// Returns: Whether the sub-type was converted in here and we should return now. void SerializeActualType(object obj, SaveInheritanceAttribute info, Type baseType, Type actualType, ref BitTarget header) { switch (info.Mode) { case SaveInheritanceMode.Index: if (!TryWriteListInheritance(info, actualType, false, ref header)) { throw new UnsupportedSubTypeException(baseType, actualType); } break; case SaveInheritanceMode.Key: WriteKeyInheritance(info, baseType, actualType, ref header); break; case SaveInheritanceMode.IndexOrKey: if (!TryWriteListInheritance(info, actualType, true, ref header)) { header.WriteBitOff(); WriteKeyInheritance(info, baseType, actualType, ref header); } break; } // Serialize the actual type now. SerializeItemNoSetup(obj, GetRuntimeMapItem(actualType), ref header, true); }
public void SerializeItem(object?obj, MapItemInfo item, ref BitTarget header) { if (obj == null) { header.WriteBitOff(); header.Apply(); } else { SerializePossibleNullableItem(obj, item, ref header); } }
public void WriteString(string?str) { var header = new BitTarget(this); if (str == null) { header.WriteBitOff(); } else { header.WriteBitOn(); WriteNonNullString(str !); } }