mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-09-22 20:13:58 +08:00
#10 move tokens to the root namespace for discoverability. upgrade xunit versions. there is a bug with test discovery for stringtokenizertests
This commit is contained in:
44
src/UglyToad.PdfPig/Tokens/StreamToken.cs
Normal file
44
src/UglyToad.PdfPig/Tokens/StreamToken.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
namespace UglyToad.PdfPig.Tokens
|
||||
{
|
||||
using Filters;
|
||||
|
||||
internal class StreamToken : IDataToken<byte[]>
|
||||
{
|
||||
private readonly object lockObject = new object();
|
||||
|
||||
private byte[] decodedBytes;
|
||||
|
||||
public DictionaryToken StreamDictionary { get; }
|
||||
|
||||
public byte[] Data { get; }
|
||||
|
||||
public StreamToken(DictionaryToken streamDictionary, byte[] data)
|
||||
{
|
||||
StreamDictionary = streamDictionary;
|
||||
Data = data;
|
||||
}
|
||||
|
||||
public byte[] Decode(IFilterProvider filterProvider)
|
||||
{
|
||||
lock (lockObject)
|
||||
{
|
||||
if (decodedBytes != null)
|
||||
{
|
||||
return decodedBytes;
|
||||
}
|
||||
|
||||
var filters = filterProvider.GetFilters(StreamDictionary);
|
||||
|
||||
var transform = Data;
|
||||
for (var i = 0; i < filters.Count; i++)
|
||||
{
|
||||
transform = filters[i].Decode(transform, StreamDictionary, i);
|
||||
}
|
||||
|
||||
decodedBytes = transform;
|
||||
|
||||
return transform;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user