CreateProtocolViolationException() публичный статический Метод

Creates the protocol violation exception.
public static CreateProtocolViolationException ( string targetType, object source ) : Exception
targetType string Type of the target.
source object The source.
Результат System.Exception
Пример #1
0
        public static char ReadChar(NetworkBinaryReader reader)
        {
            object value = ReadNonnullObject("char", reader);

            if (value is char)
            {
                return((char)value);
            }
            throw PrimitiveParser.CreateProtocolViolationException("char", value);
        }
Пример #2
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));
            }
            throw PrimitiveParser.CreateProtocolViolationException("byte", value);
        }
Пример #3
0
        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());
        }
Пример #4
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));
            }
            throw PrimitiveParser.CreateProtocolViolationException("float", value);
        }
Пример #5
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));
            }
            throw PrimitiveParser.CreateProtocolViolationException("long", value);
        }
Пример #6
0
        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);
        }
Пример #7
0
        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);
        }
Пример #8
0
        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);
        }