예제 #1
0
        // 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);
        }
예제 #2
0
        public void SerializeItem(object?obj, MapItemInfo item, ref BitTarget header)
        {
            if (obj == null)
            {
                header.WriteBitOff();
                header.Apply();
            }

            else
            {
                SerializePossibleNullableItem(obj, item, ref header);
            }
        }
예제 #3
0
        public void WriteString(string?str)
        {
            var header = new BitTarget(this);

            if (str == null)
            {
                header.WriteBitOff();
            }
            else
            {
                header.WriteBitOn();
                WriteNonNullString(str !);
            }
        }