I have an IObservable<byte[]>
that gives me an uncertain amount of bytes in the byte array. I want to know how I go from that, to returning an IObservable<byte[]>
with a set amount of bytes in each byte array. Let s assume we want 10 bytes at a time.
That is to say, if I get the following input if I were to subscribe:
{1, 2, 3, 4}
{5, 6}
{7, 8, 9}
{10}
{11, 12, 13, 14, 15}
{16}
{17, 18}
{19, 20}
Bytes.Subscribe(b => Console.WriteLine(b.Length));
产出将是
3
2
3
1
5
1
2
2
我想将上述意见转化为:
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
{11, 12, 13, 14, 15, 16, 17, 18, 19, 20}
Bytes.<WhateverItTakesToDoThat>.Subscribe(b => Console.WriteLine(b.Length));
产出将是
10
10
如果某一批的矿石数量大于单一输出包装,即:
{21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32}
{33, 34, 35, 36, 37, 38, 39, 40, 41}
{42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52}
应变成
{21, 22, 23, 24, 25, 26, 27, 28, 29, 30}
{31, 32, 33, 34, 35, 36, 37, 38, 39, 40}
{41, 42, 43, 44, 45, 46, 47, 48, 49, 50}
(待补)