コード例 #1
0
        public void ReadWriteDecimal()
        {
            IValueWriter writer = GetWriter();

            writer.WriteDecimal(Decimal.MaxValue);
            writer.WriteDecimal(Decimal.MaxValue / 2);
            writer.WriteDecimal(Decimal.MinValue);
            writer.Flush();

            IValueReader reader = GetReader(writer);

            Assert.AreEqual(Decimal.MaxValue, reader.ReadDecimal());
            Assert.AreEqual(Decimal.MaxValue / 2, reader.ReadDecimal());
            Assert.AreEqual(Decimal.MinValue, reader.ReadDecimal());
        }
コード例 #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 decimal ReadValue(IValueReader valueReader)
 {
     return(valueReader.ReadDecimal());
 }