public void ReadWriteDouble()
        {
            IValueWriter writer = GetWriter();

            writer.WriteDouble(Double.MaxValue);
            writer.WriteDouble(Double.MaxValue / 2);
            writer.WriteDouble(Double.MinValue);
            writer.Flush();

            IValueReader reader = GetReader(writer);

            Assert.AreEqual(Double.MaxValue, reader.ReadDouble());
            Assert.AreEqual(Double.MaxValue / 2, reader.ReadDouble());
            Assert.AreEqual(Double.MinValue, reader.ReadDouble());
        }
示例#2
0
        public override void OnWriteValue(int key, IValueReader valueReader)
        {
            if (typeof(TMode) == typeof(ArrayRWModes.Builder))
            {
                if (index >= content.Length)
                {
                    Extend(index * 2 + 1);
                }

                if (ValueInterface <TElement> .IsNotModified)
                {
                    if (typeof(TElement) == typeof(string))
                    {
                        Unsafe.As <string[]>(content)[index] = valueReader.ReadString();
                    }
                    else if (typeof(TElement) == typeof(int))
                    {
                        Unsafe.As <int[]>(content)[index] = valueReader.ReadInt32();
                    }
                    else if (typeof(TElement) == typeof(bool))
                    {
                        Unsafe.As <bool[]>(content)[index] = valueReader.ReadBoolean();
                    }
                    else if (typeof(TElement) == typeof(double))
                    {
                        Unsafe.As <double[]>(content)[index] = valueReader.ReadDouble();
                    }
                    else if (typeof(TElement) == typeof(long))
                    {
                        Unsafe.As <long[]>(content)[index] = valueReader.ReadInt64();
                    }
                    else if (typeof(TElement) == typeof(DateTime))
                    {
                        Unsafe.As <DateTime[]>(content)[index] = valueReader.ReadDateTime();
                    }
                    else if (typeof(TElement) == typeof(decimal))
                    {
                        Unsafe.As <decimal[]>(content)[index] = valueReader.ReadDecimal();
                    }
                    else
                    {
                        content[index] = ValueInterface <TElement> .ReadValue(valueReader);
                    }
                }
                else
                {
                    content[index] = ValueInterface <TElement> .ReadValue(valueReader);
                }

                ++index;
            }
            else
            {
                content[key] = ValueInterface <TElement> .ReadValue(valueReader);
            }
        }
示例#3
0
 public double ReadValue(IValueReader valueReader)
 {
     return(valueReader.ReadDouble());
 }
示例#4
0
 public override void ReadPayload(ISerializationContext context, IValueReader reader)
 {
     ServerClockTime = reader.ReadUniversalDate();
     Latency = reader.ReadDouble();
 }
示例#5
0
 /// <summary>
 /// When overridden in the derived class, reads a value with the specified name from an IValueReader.
 /// </summary>
 /// <param name="name">Name of the value.</param>
 /// <param name="reader">IValueReader to read from.</param>
 /// <returns>Value read from the IValueReader.</returns>
 protected override double Read(string name, IValueReader reader)
 {
     return(reader.ReadDouble(name));
 }
示例#6
0
 /// <summary>
 /// Reads a 64-bit floating-point number.
 /// </summary>
 /// <param name="name">Unique name of the value to read.</param>
 /// <returns>Value read from the reader.</returns>
 public double ReadDouble(string name)
 {
     return(_reader.ReadDouble(name));
 }