Exemplo n.º 1
0
        private byte[] Msg2bytes(Message msg, bool?stringTypeAndField)
        {
            FlexBuffer buf = new FlexBuffer();

            URL u = new URL("none:");

            if (stringTypeAndField != null)
            {
                u.AddTerm(BinaryTaggedDataOutput.STRING_TYPE_AND_FIELD, stringTypeAndField.ToString());
            }

            BinaryTaggedDataOutput btdo = new BinaryTaggedDataOutput(vf, u.ToString());

            btdo.WriteMessage(msg, buf);
            buf.SetIndex(0);
            return(buf.GetAvailBytes());
        }
Exemplo n.º 2
0
        private void assertValueToBytes(Object value, sbyte[] expectedBytes)
        {
            XType t = new XType(1, "a");
            Field f = new Field(2, "b");

            t.PutValidator(f, Validator_object.Get(0));

            Message msg = new Message(t, vf);

            msg.Add(f, value);

            BinaryTaggedDataOutput btdo = new BinaryTaggedDataOutput(vf, "none:");
            FlexBuffer             buf  = new FlexBuffer();

            btdo.WriteMessage(msg, buf);

            buf.SetIndex(0);
            byte[]  b  = buf.GetAvailBytes();
            sbyte[] b1 = new sbyte[b.Length];
            Buffer.BlockCopy(b, 0, b1, 0, b.Length);
            Dump(b);
            AssertArrayEquals(expectedBytes, b1);
        }