protected object? ReadObject()

in src/Microsoft.VisualStudio.Composition/Configuration/SerializationContextBase.cs [1014:1079]


        protected object? ReadObject()
        {
            using (this.Trace(nameof(Object)))
            {
                ObjectType objectType = this.ReadObjectType();
                switch (objectType)
                {
                    case ObjectType.Null:
                        return null;
                    case ObjectType.Array:
                        Type? elementType = this.ReadTypeRef().Resolve();
                        return this.ReadArray(this.reader, this.readObjectDelegate, elementType);
                    case ObjectType.BoolTrue:
                        return true;
                    case ObjectType.BoolFalse:
                        return false;
                    case ObjectType.Int64:
                        return this.reader.ReadInt64();
                    case ObjectType.UInt64:
                        return this.reader.ReadUInt64();
                    case ObjectType.Int32:
                        return this.reader.ReadInt32();
                    case ObjectType.UInt32:
                        return this.reader.ReadUInt32();
                    case ObjectType.Int16:
                        return this.reader.ReadInt16();
                    case ObjectType.UInt16:
                        return this.reader.ReadUInt16();
                    case ObjectType.Byte:
                        return this.reader.ReadByte();
                    case ObjectType.SByte:
                        return this.reader.ReadSByte();
                    case ObjectType.Single:
                        return this.reader.ReadSingle();
                    case ObjectType.Double:
                        return this.reader.ReadDouble();
                    case ObjectType.String:
                        return this.ReadString();
                    case ObjectType.Char:
                        return this.reader.ReadChar();
                    case ObjectType.Guid:
                        return this.ReadGuid();
                    case ObjectType.CreationPolicy:
                        return (CreationPolicy)this.reader.ReadByte();
                    case ObjectType.Type:
                        return this.ReadTypeRef().Resolve();
                    case ObjectType.TypeRef:
                        return this.ReadTypeRef();
                    case ObjectType.Enum32Substitution:
                        TypeRef? enumType = this.ReadTypeRef();
                        int rawValue = this.reader.ReadInt32();
                        return new LazyMetadataWrapper.Enum32Substitution(enumType, rawValue);
                    case ObjectType.TypeSubstitution:
                        TypeRef? typeRef = this.ReadTypeRef();
                        return new LazyMetadataWrapper.TypeSubstitution(typeRef);
                    case ObjectType.TypeArraySubstitution:
                        IReadOnlyList<TypeRef?> typeRefArray = this.ReadList(this.reader, this.readTypeRefDelegate);
                        return new LazyMetadataWrapper.TypeArraySubstitution(typeRefArray!, this.Resolver);
                    case ObjectType.BinaryFormattedObject:
                        var formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                        return formatter.Deserialize(this.reader.BaseStream);
                    default:
                        throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Strings.UnsupportedFormat, objectType));
                }
            }
        }