예제 #1
0
        public override byte[] EncodeValue(ScalarValue v)
        {
            if (v == ScalarValue.Null)
            {
                return(NullValueEncoding);
            }

            var buffer = new MemoryStream();
            var value  = (DecimalValue)v;

            try
            {
                if (Math.Abs(value.Exponent) > 63)
                {
                    Global.ErrorHandler.OnError(null, RepError.LargeDecimal, "");
                }

                byte[] tmp = NullableInteger.Encode(new IntegerValue(value.Exponent));
                buffer.Write(tmp, 0, tmp.Length);

                tmp = Integer.Encode(new LongValue(value.Mantissa));
                buffer.Write(tmp, 0, tmp.Length);
            }
            catch (IOException e)
            {
                throw new RuntimeException(e);
            }

            return(buffer.ToArray());
        }
예제 #2
0
        public override byte[] EncodeValue(ScalarValue value)
        {
            if (value.IsNull)
            {
                return(NullValueEncoding);
            }

            var diff = (TwinValue)value;

            byte[] subtractionLength = NullableInteger.Encode(diff.First);
            byte[] difference        = Ascii.Encode(diff.Second);
            var    encoded           = new byte[subtractionLength.Length + difference.Length];

            Array.Copy(subtractionLength, 0, encoded, 0, subtractionLength.Length);
            Array.Copy(difference, 0, encoded, subtractionLength.Length, difference.Length);

            return(encoded);
        }