Ejemplo n.º 1
0
Archivo: sbe.cs Proyecto: xgray/dotnet
        public override void ComplexTest()
        {
            const int bufferIndex = 0;

            messageHeader.Wrap(buffer, bufferIndex, 0);
            messageHeader.TemplateId  = Simple.TemplateId;
            messageHeader.Version     = Simple.TemplateVersion;
            messageHeader.BlockLength = Simple.BlockLength;

            complexInput.WrapForEncode(buffer, bufferIndex + MessageHeader.Size);
            SimpleType simple = complexInput.SimpleValue;

            for (int i = 0; i < simpleValue.Length; i++)
            {
                simple.SetValue(i, (byte)simpleValue[i]);
            }

            simple.ShortValue = 16;
            simple.IntValue   = 17;
            simple.LongValue  = 18;

            var listValue = complexInput.ListValueCount(2);

            listValue.Next();
            for (int i = 0; i < simpleValue.Length; i++)
            {
                listValue.SetValue(i, (byte)simpleValue[i]);
            }
            listValue.ShortValue = 16;
            listValue.IntValue   = 17;
            listValue.LongValue  = 18;

            listValue.Next();
            for (int i = 0; i < simpleValue.Length; i++)
            {
                listValue.SetValue(i, (byte)simpleValue[i]);
            }
            listValue.ShortValue = 16;
            listValue.IntValue   = 17;
            listValue.LongValue  = 18;

            messageHeader.Wrap(buffer, bufferIndex, 0);

            int actingVersion     = messageHeader.Version;
            int actingBlockLength = messageHeader.BlockLength;

            complexOutput.WrapForDecode(
                buffer,
                bufferIndex + MessageHeader.Size,
                actingBlockLength,
                actingVersion);

            simple = complexOutput.SimpleValue;

            WriteLine("{0}:{1},{2},{3},{4},{5},{6}",
                      complexInput.Size + MessageHeader.Size,
                      simple.GetValue(0),
                      simple.GetValue(1),
                      simple.GetValue(2),
                      simple.ShortValue,
                      simple.IntValue,
                      simple.LongValue);

            listValue = complexOutput.ListValue;
            while (listValue.HasNext)
            {
                listValue.Next();
                WriteLine("{0},{1},{2},{3},{4},{5}",
                          listValue.GetValue(0),
                          listValue.GetValue(1),
                          listValue.GetValue(2),
                          listValue.ShortValue,
                          listValue.IntValue,
                          listValue.LongValue);
            }
        }