public static char ReadChar(NetworkBinaryReader reader) { object value = ReadNonnullObject("char", reader); if (value is char) { return((char)value); } PrimitiveParser.InvalidConversion("char", value); return((char)0); }
public static bool ReadBool(NetworkBinaryReader reader) { object value = ReadNonnullObject("bool", reader); if (value is bool) { return((bool)value); } if (value is string) { return(PrimitiveParser.ParseBool((string)value)); } PrimitiveParser.InvalidConversion("bool", value); return(false); }
public static string ReadString(NetworkBinaryReader reader) { object value = ReadObject(reader); if (value == null) { return(null); } if (value is byte[]) { PrimitiveParser.InvalidConversion("string", value); return(null); } return(value.ToString()); }
public static byte[] ReadBytes(NetworkBinaryReader reader) { object value = ReadObject(reader); if (value == null) { return(null); } if (value is byte[]) { return((byte[])value); } PrimitiveParser.InvalidConversion("byte[]", value); return(null); }
public static double ReadDouble(NetworkBinaryReader reader) { object value = ReadNonnullObject("double", reader); if (value is double || value is float) { return((double)value); } if (value is string) { return(PrimitiveParser.ParseDouble((string)value)); } PrimitiveParser.InvalidConversion("double", value); return(0); }
public static float ReadSingle(NetworkBinaryReader reader) { object value = ReadNonnullObject("float", reader); if (value is float) { return((float)value); } if (value is string) { return(PrimitiveParser.ParseFloat((string)value)); } PrimitiveParser.InvalidConversion("float", value); return(0); }
public static long ReadInt64(NetworkBinaryReader reader) { object value = ReadNonnullObject("long", reader); if (value is long || value is int || value is short || value is byte) { return((long)value); } if (value is string) { return(PrimitiveParser.ParseLong((string)value)); } PrimitiveParser.InvalidConversion("long", value); return(0); }
public static byte ReadByte(NetworkBinaryReader reader) { object value = ReadNonnullObject("byte", reader); if (value is byte) { return((byte)value); } if (value is string) { return(PrimitiveParser.ParseByte((string)value)); } PrimitiveParser.InvalidConversion("byte", value); return(0); }
public static short ReadInt16(NetworkBinaryReader reader) { object value = ReadNonnullObject("short", reader); if (value is short || value is byte) { return((short)value); } if (value is string) { return(PrimitiveParser.ParseShort((string)value)); } PrimitiveParser.InvalidConversion("short", value); return(0); }