/// <summary> /// Parses the specified sort expression. /// </summary> /// <param name="sortExpression"></param> /// <returns></returns> private static IEnumerable <SortDescription> ParseSortExpression(string sortExpression) { var sortExpressions = sortExpression.Split(new[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (var sort in sortExpressions) { SortDescription sortDescription; if (SortDescription.TryParse(sort, out sortDescription)) { yield return(sortDescription); } } }
/// <summary> /// Tries the parse. /// </summary> /// <param name="sortExpression"> The sort expression. </param> /// <param name="sortDescription"> The sort description. </param> /// <returns> </returns> public static bool TryParse(string sortExpression, out SortDescription sortDescription) { if (string.IsNullOrWhiteSpace(sortExpression)) { sortDescription = null; return(false); } try { sortDescription = Parse(sortExpression); return(true); } catch (FormatException) { sortDescription = null; return(false); } }