Exemplo n.º 1
0
        public bool ReadBoolean()
        {
            FailIfWriteOnlyMsgBody();
            FailIfBytesInBuffer();
            bool   result;
            object value = cloak.Peek();

            if (value == null)
            {
                result = Convert.ToBoolean(value);
            }
            else
            {
                result = ConversionSupport.ConvertNMSType <bool>(value);
            }
            cloak.Pop();
            return(result);
        }
Exemplo n.º 2
0
        public string ReadString()
        {
            FailIfWriteOnlyMsgBody();
            FailIfBytesInBuffer();
            string result;
            object value = cloak.Peek();

            if (value == null)
            {
                result = Convert.ToString(null);
            }
            else
            {
                result = ConversionSupport.ConvertNMSType <string>(value);
            }

            cloak.Pop();
            return(result);
        }
Exemplo n.º 3
0
        public float ReadSingle()
        {
            FailIfWriteOnlyMsgBody();
            FailIfBytesInBuffer();
            float  result;
            object value = cloak.Peek();

            if (value == null)
            {
                result = Convert.ToSingle(null);
            }
            else
            {
                result = ConversionSupport.ConvertNMSType <float>(value);
            }

            cloak.Pop();
            return(result);
        }
Exemplo n.º 4
0
        public int ReadInt32()
        {
            FailIfWriteOnlyMsgBody();
            FailIfBytesInBuffer();
            int    result;
            object value = cloak.Peek();

            if (value == null)
            {
                result = Convert.ToInt32(null);
            }
            else
            {
                result = ConversionSupport.ConvertNMSType <int>(value);
            }

            cloak.Pop();
            return(result);
        }
Exemplo n.º 5
0
        public double ReadDouble()
        {
            FailIfWriteOnlyMsgBody();
            FailIfBytesInBuffer();
            double result;
            object value = cloak.Peek();

            if (value == null)
            {
                result = Convert.ToDouble(null);
            }
            else
            {
                result = ConversionSupport.ConvertNMSType <double>(value);
            }

            cloak.Pop();
            return(result);
        }
Exemplo n.º 6
0
        public char ReadChar()
        {
            FailIfWriteOnlyMsgBody();
            FailIfBytesInBuffer();
            char   result;
            object value = cloak.Peek();

            if (value == null)
            {
                throw new NullReferenceException("Cannot convert NULL value to char.");
            }
            else
            {
                result = ConversionSupport.ConvertNMSType <char>(value);
            }

            cloak.Pop();
            return(result);
        }