private object?LoadObjectV1(int dataOffset) { Debug.Assert(System.Threading.Monitor.IsEntered(reader)); reader.Seek(dataSectionPosition + dataOffset, SeekOrigin.Begin); int typeIndex = reader.Read7BitEncodedInt(); if (typeIndex == -1) { return(null); } string typeName = FindType(typeIndex); int comma = typeName.IndexOf(','); if (comma > 0) { // strip assembly name typeName = typeName.Substring(0, comma); } switch (typeName) { case "System.String": return(reader.ReadString()); case "System.Byte": return(reader.ReadByte()); case "System.SByte": return(reader.ReadSByte()); case "System.Int16": return(reader.ReadInt16()); case "System.UInt16": return(reader.ReadUInt16()); case "System.Int32": return(reader.ReadInt32()); case "System.UInt32": return(reader.ReadUInt32()); case "System.Int64": return(reader.ReadInt64()); case "System.UInt64": return(reader.ReadUInt64()); case "System.Single": return(reader.ReadSingle()); case "System.Double": return(reader.ReadDouble()); case "System.DateTime": // Ideally we should use DateTime's ToBinary & FromBinary, // but we can't for compatibility reasons. return(new DateTime(reader.ReadInt64())); case "System.TimeSpan": return(new TimeSpan(reader.ReadInt64())); case "System.Decimal": int[] bits = new int[4]; for (int i = 0; i < bits.Length; i++) { bits[i] = reader.ReadInt32(); } return(new decimal(bits)); default: return(new ResourceSerializedObject(FindType(typeIndex), this, reader.BaseStream.Position)); } }
private Record <float> ParseFloatConstant(MyBinaryReader reader) => new Record <float>(reader.ReadSingle());