mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-04-06 06:11:45 +00:00
This change looks dramatic, but it's just separating out the already-split namespaces into separate top-level folders. In theory, every single one could be built into their own Nuget package. `SabreTools.Serialization` still builds the normal Nuget package that is used by all other projects and includes all namespaces.
51 lines
1.2 KiB
C#
51 lines
1.2 KiB
C#
#if NET20 || NET35
|
|
|
|
using System;
|
|
using System.IO;
|
|
|
|
namespace SabreTools.Serialization.CrossModel
|
|
{
|
|
/// <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)
|
|
{
|
|
if (destination is null)
|
|
{
|
|
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
|