aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common.Implementations/IO/MemoryStreamProvider.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Common.Implementations/IO/MemoryStreamProvider.cs')
-rw-r--r--MediaBrowser.Common.Implementations/IO/MemoryStreamProvider.cs31
1 files changed, 31 insertions, 0 deletions
diff --git a/MediaBrowser.Common.Implementations/IO/MemoryStreamProvider.cs b/MediaBrowser.Common.Implementations/IO/MemoryStreamProvider.cs
new file mode 100644
index 000000000..364055283
--- /dev/null
+++ b/MediaBrowser.Common.Implementations/IO/MemoryStreamProvider.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using MediaBrowser.Common.IO;
+using Microsoft.IO;
+
+namespace MediaBrowser.Common.Implementations.IO
+{
+ public class MemoryStreamProvider : IMemoryStreamProvider
+ {
+ 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);
+ }
+ }
+}