|
6 | 6 | using System; |
7 | 7 | using System.Buffers; |
8 | 8 |
|
9 | | -namespace Magick.NET.Tests |
| 9 | +namespace Magick.NET.Tests; |
| 10 | + |
| 11 | +internal sealed class TestReadOnlySequence : ReadOnlySequenceSegment<byte> |
10 | 12 | { |
11 | | - internal sealed class TestReadOnlySequence : ReadOnlySequenceSegment<byte> |
| 13 | + private TestReadOnlySequence(byte[] value, int start, int length) |
12 | 14 | { |
13 | | - private TestReadOnlySequence(byte[] value, int start, int length) |
14 | | - { |
15 | | - Memory = new ReadOnlyMemory<byte>(value, start, length); |
16 | | - } |
17 | | - |
18 | | - public static ReadOnlySequence<byte> Create(byte[] data, int sequenceSize) |
19 | | - { |
20 | | - var first = new TestReadOnlySequence(data, 0, sequenceSize); |
21 | | - var length = sequenceSize; |
22 | | - var last = first.Append(data, sequenceSize, length); |
| 15 | + Memory = new ReadOnlyMemory<byte>(value, start, length); |
| 16 | + } |
23 | 17 |
|
24 | | - for (var i = sequenceSize + sequenceSize; i < data.Length; i += sequenceSize) |
25 | | - { |
26 | | - length = Math.Min(data.Length - i, sequenceSize); |
27 | | - last = last.Append(data, i, length); |
28 | | - } |
| 18 | + public static ReadOnlySequence<byte> Create(byte[] data, int sequenceSize) |
| 19 | + { |
| 20 | + var first = new TestReadOnlySequence(data, 0, sequenceSize); |
| 21 | + var length = sequenceSize; |
| 22 | + var last = first.Append(data, sequenceSize, length); |
29 | 23 |
|
30 | | - return new ReadOnlySequence<byte>(first, 0, last, length); |
| 24 | + for (var i = sequenceSize + sequenceSize; i < data.Length; i += sequenceSize) |
| 25 | + { |
| 26 | + length = Math.Min(data.Length - i, sequenceSize); |
| 27 | + last = last.Append(data, i, length); |
31 | 28 | } |
32 | 29 |
|
33 | | - private TestReadOnlySequence Append(byte[] value, int start, int length) |
| 30 | + return new ReadOnlySequence<byte>(first, 0, last, length); |
| 31 | + } |
| 32 | + |
| 33 | + private TestReadOnlySequence Append(byte[] value, int start, int length) |
| 34 | + { |
| 35 | + var next = new TestReadOnlySequence(value, start, length) |
34 | 36 | { |
35 | | - var next = new TestReadOnlySequence(value, start, length) |
36 | | - { |
37 | | - RunningIndex = RunningIndex + Memory.Length, |
38 | | - }; |
| 37 | + RunningIndex = RunningIndex + Memory.Length, |
| 38 | + }; |
39 | 39 |
|
40 | | - Next = next; |
| 40 | + Next = next; |
41 | 41 |
|
42 | | - return next; |
43 | | - } |
| 42 | + return next; |
44 | 43 | } |
45 | 44 | } |
46 | 45 |
|
|
0 commit comments