Exemplo n.º 1
0
        public void TestDecode()
        {
            const string message = "11000000 10000010 10000010";
            Stream inp = new MemoryStream(ByteUtil.ConvertBitStringToFastByteArray(message));
            var firstname = new Scalar("firstName", FastType.U32, Operator.Copy,
                                       ScalarValue.Undefined, true);
            var lastName = new Scalar("lastName", FastType.U32, Operator.None,
                                      ScalarValue.Undefined, false);

            // MessageInputStream in = new MessageInputStream(new
            // ByteArrayInputStream(message.getBytes()));
            var group = new Group("person", new Field[] {firstname, lastName}, false);
            var groupValue = (GroupValue) group.Decode(inp, _template, _context, BitVectorReader.InfiniteTrue);
            Assert.AreEqual(1, ((IntegerValue) groupValue.GetValue(0)).Value);
            Assert.AreEqual(2, ((IntegerValue) groupValue.GetValue(1)).Value);
        }
Exemplo n.º 2
0
        public override FieldValue Decode(System.IO.Stream in_Renamed, Group decodeTemplate, Context context, BitVectorReader pmapReader)
        {
            var        sequenceValue = new SequenceValue(this);
            FieldValue lengthValue   = length.Decode(in_Renamed, decodeTemplate, context, pmapReader);

            if ((lengthValue == ScalarValue.NULL) || (lengthValue == null))
            {
                return(null);
            }

            int len = ((IntegerValue)lengthValue).value_Renamed;

            for (var i = 0; i < len; i++)
            {
                sequenceValue.Add((GroupValue)group.Decode(in_Renamed, decodeTemplate, context, BitVectorReader.INFINITE_TRUE));
            }

            return(sequenceValue);
        }
Exemplo n.º 3
0
        public override IFieldValue Decode(Stream inStream, Group decodeTemplate, Context context,
                                           BitVectorReader pmapReader)
        {
            var         sequenceValue = new SequenceValue(this);
            IFieldValue lengthValue   = _length.Decode(inStream, decodeTemplate, context, pmapReader);

            if ((lengthValue == ScalarValue.Null) || (lengthValue == null))
            {
                return(null);
            }

            int len = ((IntegerValue)lengthValue).Value;

            for (int i = 0; i < len; i++)
            {
                sequenceValue.Add(
                    (GroupValue)_group.Decode(inStream, decodeTemplate, context, BitVectorReader.InfiniteTrue));
            }

            return(sequenceValue);
        }