Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 1f6fb92

Browse files
committed
SL5 can't handle RecyclableMemoryStream so gets none
1 parent 184af39 commit 1f6fb92

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

src/ServiceStack.Text/RecyclableMemoryStream.cs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ namespace ServiceStack.Text //Internalize to avoid conflicts
3434

3535
public static class MemoryStreamFactory
3636
{
37-
public static RecyclableMemoryStreamManager RecyclableInstance = new RecyclableMemoryStreamManager();
38-
3937
public static bool UseRecyclableMemoryStream { get; set; }
4038

39+
#if !SL5
40+
public static RecyclableMemoryStreamManager RecyclableInstance = new RecyclableMemoryStreamManager();
41+
4142
public static MemoryStream CreateMemoryStream()
4243
{
4344
return UseRecyclableMemoryStream
@@ -58,8 +59,25 @@ public static MemoryStream CreateMemoryStream(byte[] bytes, int index, int count
5859
? RecyclableInstance.GetStream(typeof(MemoryStreamFactory).Name, bytes, index, count)
5960
: new MemoryStream(bytes, index, count);
6061
}
62+
#else
63+
public static MemoryStream CreateMemoryStream()
64+
{
65+
return new MemoryStream();
66+
}
67+
68+
public static MemoryStream CreateMemoryStream(byte[] bytes)
69+
{
70+
return new MemoryStream(bytes);
71+
}
72+
73+
public static MemoryStream CreateMemoryStream(byte[] bytes, int index, int count)
74+
{
75+
return new MemoryStream(bytes, index, count);
76+
}
77+
#endif
6178
}
6279

80+
#if !SL5
6381
/// <summary>
6482
/// Manages pools of RecyclableMemoryStream objects.
6583
/// </summary>
@@ -1495,6 +1513,7 @@ private void ReleaseLargeBuffer()
14951513
#endregion
14961514
}
14971515

1516+
//Avoid taking on an extra dep
14981517
public sealed partial class RecyclableMemoryStreamManager
14991518
{
15001519
//[EventSource(Name = "Microsoft-IO-RecyclableMemoryStream", Guid = "{B80CD4E4-890E-468D-9CBA-90EB7C82DFC7}")]
@@ -1618,5 +1637,5 @@ public void MemoryStreamOverCapacity(int requestedCapacity, long maxCapacity, st
16181637
}
16191638
}
16201639
}
1621-
1640+
#endif
16221641
}

0 commit comments

Comments
 (0)