using System;
namespace Unity.Cloud
{
///
/// Provides static methods for helping with preconditions.
///
public static class Preconditions
{
#region Static Methods
///
/// Ensures that an argument is less than or equal to the specified length.
///
/// The value.
/// The length.
/// The argument name.
public static void ArgumentIsLessThanOrEqualToLength(object value, int length, string argumentName)
{
string stringValue = value as string;
if (stringValue != null && stringValue.Length > length)
{
throw new ArgumentException(argumentName);
}
}
///
/// Ensures that an argument is not null or whitespace.
///
/// The value.
/// The argument name.
public static void ArgumentNotNullOrWhitespace(object value, string argumentName)
{
if (value == null)
{
throw new ArgumentNullException(argumentName);
}
string stringValue = value as string;
if (stringValue != null && stringValue.Trim() == string.Empty)
{
throw new ArgumentNullException(argumentName);
}
}
#endregion
}
}