コード例 #1
0
        public static object Take(object input, int count)
        {
            var blogPostsDrop = input as BlogPostsDrop;

            if (blogPostsDrop != null)
            {
                return(BlogFunctions.Take(blogPostsDrop, count));
            }

            var forumThreadsDrop = input as ForumThreadsDrop;

            if (forumThreadsDrop != null)
            {
                return(ForumFunctions.Take(forumThreadsDrop, count));
            }

            var forumPostsDrop = input as ForumPostsDrop;

            if (forumPostsDrop != null)
            {
                return(ForumFunctions.Take(forumPostsDrop, count));
            }

            var enumerable = input as IEnumerable;

            if (enumerable != null)
            {
                return(enumerable.Cast <object>().Take(count));
            }

            return(input);
        }
コード例 #2
0
        public static object OrderBy(object input, string key, string direction = "asc")
        {
            var blogPostsDrop = input as BlogPostsDrop;

            if (blogPostsDrop != null)
            {
                return(BlogFunctions.OrderBy(blogPostsDrop, key, direction));
            }

            var forumThreadsDrop = input as ForumThreadsDrop;

            if (forumThreadsDrop != null)
            {
                return(ForumFunctions.OrderBy(forumThreadsDrop, key, direction));
            }

            var enumerable = input as IEnumerable;

            if (enumerable != null)
            {
                return(string.Equals(direction, "desc", StringComparison.InvariantCultureIgnoreCase) ||
                       string.Equals(direction, "descending", StringComparison.InvariantCultureIgnoreCase)
                                        ? enumerable.Cast <object>().OrderByDescending(e => Get(e, key))
                                        : enumerable.Cast <object>().OrderBy(e => Get(e, key)));
            }

            return(input);
        }
コード例 #3
0
        public static object All(object input)
        {
            var blogPostsDrop = input as BlogPostsDrop;

            if (blogPostsDrop != null)
            {
                return(BlogFunctions.All(blogPostsDrop));
            }

            var forumThreadsDrop = input as ForumThreadsDrop;

            if (forumThreadsDrop != null)
            {
                return(ForumFunctions.All(forumThreadsDrop));
            }

            var forumPostsDrop = input as ForumPostsDrop;

            if (forumPostsDrop != null)
            {
                return(ForumFunctions.All(forumPostsDrop));
            }

            var enumerable = input as IEnumerable;

            if (enumerable != null)
            {
                return(enumerable);
            }

            return(input);
        }