2016-10-13 14:13:30 -07:00
|
|
|
|
using System.IO;
|
2016-10-06 11:55:01 -07:00
|
|
|
|
using MediaBrowser.Common.IO;
|
|
|
|
|
using Microsoft.IO;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Common.Implementations.IO
|
|
|
|
|
{
|
2016-10-13 14:13:30 -07:00
|
|
|
|
public class RecyclableMemoryStreamProvider : IMemoryStreamProvider
|
2016-10-06 11:55:01 -07:00
|
|
|
|
{
|
|
|
|
|
readonly RecyclableMemoryStreamManager _manager = new RecyclableMemoryStreamManager();
|
|
|
|
|
|
|
|
|
|
public MemoryStream CreateNew()
|
|
|
|
|
{
|
|
|
|
|
return _manager.GetStream();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public MemoryStream CreateNew(int capacity)
|
|
|
|
|
{
|
|
|
|
|
return _manager.GetStream("RecyclableMemoryStream", capacity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public MemoryStream CreateNew(byte[] buffer)
|
|
|
|
|
{
|
|
|
|
|
return _manager.GetStream("RecyclableMemoryStream", buffer, 0, buffer.Length);
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-10-13 14:13:30 -07:00
|
|
|
|
|
|
|
|
|
public class MemoryStreamProvider : IMemoryStreamProvider
|
|
|
|
|
{
|
|
|
|
|
public MemoryStream CreateNew()
|
|
|
|
|
{
|
|
|
|
|
return new MemoryStream();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public MemoryStream CreateNew(int capacity)
|
|
|
|
|
{
|
|
|
|
|
return new MemoryStream(capacity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public MemoryStream CreateNew(byte[] buffer)
|
|
|
|
|
{
|
|
|
|
|
return new MemoryStream(buffer);
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-10-06 11:55:01 -07:00
|
|
|
|
}
|