public static ListSortDirection GetSortDirection(string sortOrder, ListSortDirection? defaultDirection = null)
{
if (sortOrder == null)
throw new ArgumentNullException("sortOrder");
if (String.IsNullOrWhiteSpace(sortOrder))
{
if (defaultDirection == null)
throw new ArgumentOutOfRangeException("sortOrder", sortOrder, INVALID_SORT_ORDER);
return defaultDirection.Value;
}
switch (sortOrder.ToUpper())
{
case "ASC":
case "ASCENDING":
return ListSortDirection.Ascending;
case "DESC":
case "DESCENDING":
return ListSortDirection.Descending;
default:
throw new ArgumentOutOfRangeException("sortOrder", sortOrder, INVALID_SORT_ORDER);
}
}