public static CreateProtocolViolationException ( string targetType, object source ) : |
||
targetType | string | Type of the target. |
source | object | The source. |
return |
public static char ReadChar(NetworkBinaryReader reader) { object value = ReadNonnullObject("char", reader); if (value is char) { return((char)value); } throw PrimitiveParser.CreateProtocolViolationException("char", value); }
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)); } throw PrimitiveParser.CreateProtocolViolationException("byte", value); }
public static string ReadString(NetworkBinaryReader reader) { object value = ReadObject(reader); if (value == null) { return(null); } if (value is byte[]) { throw PrimitiveParser.CreateProtocolViolationException("string", value); } return(value.ToString()); }
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)); } throw PrimitiveParser.CreateProtocolViolationException("float", value); }
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)); } throw PrimitiveParser.CreateProtocolViolationException("long", value); }
public static int ReadInt32(NetworkBinaryReader reader) { object value = ReadNonnullObject("int", reader); if (value is int || value is short || value is byte) { return((int)value); } if (value is string) { return(PrimitiveParser.ParseInt((string)value)); } throw PrimitiveParser.CreateProtocolViolationException("int", value); }
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)); } throw PrimitiveParser.CreateProtocolViolationException("double", value); }
public static byte[] ReadBytes(NetworkBinaryReader reader) { object value = ReadObject(reader); if (value == null) { return(null); } if (value is byte[]) { return((byte[])value); } throw PrimitiveParser.CreateProtocolViolationException("byte[]", value); }