Application.Common.Helper.GetSortDirection C# (CSharp) Method

GetSortDirection() public static method

public static GetSortDirection ( string sortOrder, ListSortDirection defaultDirection = null ) : ListSortDirection
sortOrder string
defaultDirection ListSortDirection
return ListSortDirection
        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);
            }
        }