// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.IO;
namespace CommunityToolkit.HighPerformance.Streams;
///
/// A factory class to produce instances.
///
internal static partial class MemoryStream
{
///
/// Gets a standard instance for a stream.
///
/// A with the standard text.
public static Exception GetNotSupportedException()
{
return new NotSupportedException("The requested operation is not supported for this stream.");
}
///
/// Throws a when trying to perform a not supported operation.
///
public static void ThrowNotSupportedException()
{
throw GetNotSupportedException();
}
///
/// Throws an when trying to write too many bytes to the target stream.
///
public static void ThrowArgumentExceptionForEndOfStreamOnWrite()
{
throw new ArgumentException("The current stream can't contain the requested input data.");
}
///
/// Throws an when using an invalid seek mode.
///
/// Nothing, as this method throws unconditionally.
public static long ThrowArgumentExceptionForSeekOrigin()
{
throw new ArgumentException("The input seek mode is not valid.", "origin");
}
///
/// Throws an when setting the property.
///
private static void ThrowArgumentOutOfRangeExceptionForPosition()
{
throw new ArgumentOutOfRangeException(nameof(Stream.Position), "The value for the property was not in the valid range.");
}
///
/// Throws an when an input buffer is .
///
private static void ThrowArgumentNullExceptionForBuffer()
{
throw new ArgumentNullException("buffer", "The buffer is null.");
}
///
/// Throws an when the input count is negative.
///
private static void ThrowArgumentOutOfRangeExceptionForOffset()
{
throw new ArgumentOutOfRangeException("offset", "Offset can't be negative.");
}
///
/// Throws an when the input count is negative.
///
private static void ThrowArgumentOutOfRangeExceptionForCount()
{
throw new ArgumentOutOfRangeException("count", "Count can't be negative.");
}
///
/// Throws an when the sum of offset and count exceeds the length of the target buffer.
///
private static void ThrowArgumentExceptionForLength()
{
throw new ArgumentException("The sum of offset and count can't be larger than the buffer length.", "buffer");
}
///
/// Throws an when using a disposed instance.
///
private static void ThrowObjectDisposedException()
{
throw new ObjectDisposedException("source", "The current stream has already been disposed");
}
}