Exemplo n.º 1
0
        /// <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);
                }
            }
        }
Exemplo n.º 2
0
        /// <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);
            }
        }