Exemplo n.º 1
0
        public static float ReadValue <TInput>(ref Reader <TInput> reader, Field field)
        {
            ReferenceCodec.MarkValueField(reader.Session);
            switch (field.WireType)
            {
            case WireType.Fixed32:
                return(ReadFloatRaw(ref reader));

            case WireType.Fixed64:
            {
                var value = DoubleCodec.ReadDoubleRaw(ref reader);
                if ((value > float.MaxValue || value < float.MinValue) && !double.IsInfinity(value) && !double.IsNaN(value))
                {
                    ThrowValueOutOfRange(value);
                }

                return((float)value);
            }

            case WireType.LengthPrefixed:
                return((float)DecimalCodec.ReadDecimalRaw(ref reader));

            default:
                ThrowWireTypeOutOfRange(field.WireType);
                return(0);
            }
        }
Exemplo n.º 2
0
        public static double ReadValue <TInput>(ref Reader <TInput> reader, Field field)
        {
            ReferenceCodec.MarkValueField(reader.Session);
            switch (field.WireType)
            {
            case WireType.Fixed32:
                return(FloatCodec.ReadFloatRaw(ref reader));

            case WireType.Fixed64:
                return(ReadDoubleRaw(ref reader));

            case WireType.LengthPrefixed:
                return((double)DecimalCodec.ReadDecimalRaw(ref reader));

            default:
                ThrowWireTypeOutOfRange(field.WireType);
                return(0);
            }
        }