public static DataTable DeserializeDataTable(BinaryTypesReader br) { DataTable table = new DataTable(); table.TableName = br.ReadString(); int columnCount = br.Read7BitInt(); Type[] columnTypes = new Type[columnCount]; for (int i = 0; i < columnCount; i++) { string columnName = br.ReadString(); string typeName = br.ReadString(); Type columnType = Type.GetType(typeName); DataColumn col = new DataColumn(columnName, columnType); table.Columns.Add(col); columnTypes[i] = columnType; } int rowsCount = br.Read7BitInt(); for (int rowIndex = 0; rowIndex < rowsCount; rowIndex++) { DataRow row = table.NewRow(); table.Rows.Add(row); for (int i = 0; i < columnCount; i++) { if (columnTypes[i] == typeof(System.String)) { row[i] = br.ReadString(); } else if (columnTypes[i] == typeof(System.Int32)) { row[i] = br.Read7BitInt(); } else if (columnTypes[i] == typeof(System.Int64)) { row[i] = br.Read7BitLong(); } else if (columnTypes[i] == typeof(System.Decimal)) { row[i] = br.ReadCompactDecimal(); } else if (columnTypes[i] == typeof(System.DateTime)) { row[i] = br.ReadCompactDateTime(TimeSpan.TicksPerMillisecond * 100); } else if (columnTypes[i] == typeof(bool)) { row[i] = br.ReadBoolean(); } } } return(table); }
internal static object DeserializeObject(BinaryTypesReader br, Type type, SerializerSettings settings, ISerializer serializer, ISerializerArg serializerArg) { serializer = GetSerializer(type, serializer); if (serializer == null) { throw new Exception($"SerializeObject: serializer not found for type {type.FullName}"); } if (type.IsClass && serializer.CommonNullHandle) { if (br.ReadBoolean() == false) //null { return(null); } } return(serializer.Deserialize(br, type, settings, serializerArg)); }
/////////////////////////////////////////////////////////////////////// public static bool ReadBool(BinaryTypesReader br, object objParam) { return(br.ReadBoolean()); }