public static IsNullorWhiteSpace ( item, string nameOfTheArgument = "" ) : void | ||
item | The item you want to check | |
nameOfTheArgument | string | Name of the argument |
return | void |
public static void IsNullorWhiteSpace<T>(T item, string nameOfTheArgument = "")
{
Type type = typeof(T);
if (type == typeof(string) ||
type == typeof(String))
{
if (string.IsNullOrWhiteSpace(item as string))
{
throw new ArgumentException(nameOfTheArgument + " is null or Whitespace");
}
}
else
{
if (item == null)
{
throw new ArgumentException(nameOfTheArgument + " is null");
}
}
}
}
/// <summary> /// Changes all elements of IEnumerable by the change function /// </summary> /// <param name="enumerable">The enumerable where you want to change stuff</param> /// <param name="change">The way you want to change the stuff</param> /// <returns>An IEnumerable with all changes applied</returns> public static IEnumerable <T> Change <T>(this IEnumerable <T> enumerable, Func <T, T> change) { ArgumentCheck.IsNullorWhiteSpace(enumerable, "enumerable"); ArgumentCheck.IsNullorWhiteSpace(change, "change"); foreach (var item in enumerable) { yield return(change(item)); } }