Files
SabreTools.Serialization/SabreTools.Serialization.CrossModel/OldDotNet.cs

51 lines
1.2 KiB
C#
Raw Normal View History

2023-11-21 20:59:20 -05:00
#if NET20 || NET35
using System;
using System.IO;
namespace SabreTools.Serialization.CrossModel
2023-11-21 20:59:20 -05:00
{
/// <summary>
/// Derived from the mscorlib code from .NET Framework 4.0
/// </summary>
internal static class OldDotNet
{
public static void CopyTo(this Stream source, Stream destination)
{
2026-01-25 14:30:18 -05:00
if (destination is null)
2023-11-21 20:59:20 -05:00
{
throw new ArgumentNullException("destination");
}
if (!source.CanRead && !source.CanWrite)
{
throw new ObjectDisposedException(null);
}
if (!destination.CanRead && !destination.CanWrite)
{
throw new ObjectDisposedException("destination");
}
if (!source.CanRead)
{
throw new NotSupportedException();
}
if (!destination.CanWrite)
{
throw new NotSupportedException();
}
byte[] array = new byte[81920];
int count;
while ((count = source.Read(array, 0, array.Length)) != 0)
{
destination.Write(array, 0, count);
}
}
}
}
#endif