/// <summary>
        /// Filters the collection, leaving only the pages which 
        /// correspond to the given page number and size.
        /// </summary>
        /// <param name="pages"></param>
        public void Filter(PageDataCollection pages)
        {
            for (int i = pages.Count - 1; i > -1; i--)
            {
                if (i >= _pageNumber * _pageSize)
                    pages.RemoveAt(i);

                if (i < (_pageNumber - 1) * _pageSize)
                    pages.RemoveAt(i);
            }
        }
 /// <summary>
 /// Filters the specified collection, removing pages of types not specified in
 /// the constructor. 
 /// </summary>
 /// <param name="pages"></param>
 public void Filter(PageDataCollection pages)
 {
     for (int i = pages.Count - 1; i > -1; i--)
     {
         if (ShouldFilter(pages[i]))
             pages.RemoveAt(i);
     }
 }
Example #3
0
 /// <summary>
 /// Removes any page not of the specified type from the page collection
 /// </summary>
 /// <param name="pages">The page collection to filter</param>
 /// <param name="pageTypeId">Page type ID of pages that should be left in the page collection</param>
 public static void FilterByPageType(this PageDataCollection pages, int pageTypeId)
 {
     for (var i = pages.Count - 1; i >= 0; i--)
     {
         if (pages[i].ContentTypeID != pageTypeId)
         {
             pages.RemoveAt(i);
         }
     }
 }
Example #4
0
        /// <summary>
        /// Removes any page not matching any of the specified categories
        /// </summary>
        /// <param name="pages">The page collection to filter</param>
        /// <param name="categories">Categories used for filtering, pages not matching at least one category will be filtered out</param>
        public static void FilterByCategories(this PageDataCollection pages, CategoryList categories)
        {
            if (categories == null || !categories.Any())
            {
                return;
            }

            for (var i = pages.Count - 1; i >= 0; i--)
            {
                var atLeastOneCategoryMatches = categories.Any(c => pages[i].Category.Contains(c));

                if (!atLeastOneCategoryMatches)
                {
                    pages.RemoveAt(i);
                }
            }
        }
Example #5
0
        /// <summary>
        /// Validates the pages.
        /// </summary>
        /// <param name="pages">The pages.</param>
        private void ValidatePages(PageDataCollection pages)
        {
            bool ignoreInvalidPages = this.IgnoreInvalidPages;

            for (int i = pages.Count - 1; i >= 0; i--)
            {
                PageData data = pages[i];
                if ((data.Property[EVENT_START_DATE_PROPERTY_NAME] == null) || (data.Property[EVENT_STOP_DATE_PROPERTY_NAME] == null))
                {
                    if (!ignoreInvalidPages)
                    {
                        throw new EPiServerException("Calendar pages must include properties EventStartDate and EventStopDate");
                    }
                    pages.RemoveAt(i);
                }
            }
        }