예제 #1
0
파일: Blog.cs 프로젝트: gillismr/dev
        /// <summary>
        /// Returns a copy of the internal array of BlogItem objects
        /// to be manipulated as desired by the caller.
        ///
        /// The items are in order of the earliest date of the html
        /// content files.
        /// </summary>
        public BlogItem[] GetBlogItems()
        {
            int n = items.Length;

            BlogItem[] copy = new BlogItem[n];

            for (int i = 0; i < n; i++)
            {
                copy[i] = items[i];
            }

            return(copy);
        }
예제 #2
0
파일: Blog.cs 프로젝트: gillismr/dev
        /// <summary>
        /// Returns a List of int[] objects in which each int[] is a triple
        /// consisting of a year, month, and count where count is the number
        /// of blog items that occur in that month.
        /// </summary>
        public int[][] GetYearMonthCountList()
        {
            List <int[]> list = new List <int[]>();

            int n = items.Length;

            if (n > 0)
            {
                int index = 0;

                BlogItem item     = items[index];
                DateTime datetime = item.BlogItemEarliestTime;
                int      year0    = datetime.Year;
                int      month0   = datetime.Month;

                int[] triple = new int[] { year0, month0, 1 };

                index++;

                while (index < n)
                {
                    item     = items[index];
                    datetime = item.BlogItemEarliestTime;

                    int year1  = datetime.Year;
                    int month1 = datetime.Month;

                    if ((year1 == year0) && (month1 == month0))
                    {
                        triple[2]++;
                    }
                    else
                    {
                        list.Add(triple);
                        year0  = year1;
                        month0 = month1;
                        triple = new int[] { year0, month0, 1 };
                    }

                    index++;
                }

                list.Add(triple);
            }
            return((int[][])list.ToArray());
        }
예제 #3
0
파일: Blog.cs 프로젝트: gillismr/dev
        static int minimumRecentItems = 5; // minimum number of recent items

        /// <summary>
        /// The constructor constructs an internal array of BlogItem objects
        /// based the given Page object and the given directory of html
        /// content files in the directory specified by a url given relative
        /// to the location of the page.
        ///
        /// This class can return the html for a blog based on this data.
        /// The blog html may be arranged in order of earliest date or in
        /// reverse order.  The blog html may be restricted to content
        /// created in a particular month and year if desired.
        ///
        /// This class can return a copy of all BlogItem data for further
        /// manipulation by the caller.
        /// </summary>
        /// <param name="page">The blog page to load.</param>
        /// <param name="relativePath">The relative path from the directory
        /// of the blog page to the directory of the html content files.</param>
        public Blog(Page page, string relativePath)
        {
            string fullPath = page.Server.MapPath(relativePath);

            DirectoryInfo info = new DirectoryInfo(fullPath);

            FileInfo[] files = info.GetFiles("*.htm");
            int        n     = files.Length;

            if (n > 0)
            {
                Array.Sort <FileInfo>(files, CompareEarliestTimes.Comparer);
            }

            items = new BlogItem[n];

            for (int i = 0; i < n; i++)
            {
                items[i] = new BlogItem(files[i]);
            }
        }
예제 #4
0
파일: Blog.cs 프로젝트: rewanth21/freetime
        /// <summary>
        /// The constructor constructs an internal array of BlogItem objects
        /// based the given Page object and the given directory of html
        /// content files in the directory specified by a url given relative
        /// to the location of the page.
        /// 
        /// This class can return the html for a blog based on this data.
        /// The blog html may be arranged in order of earliest date or in
        /// reverse order.  The blog html may be restricted to content
        /// created in a particular month and year if desired.
        /// 
        /// This class can return a copy of all BlogItem data for further
        /// manipulation by the caller.
        /// </summary>
        /// <param name="page">The blog page to load.</param>
        /// <param name="relativePath">The relative path from the directory
        /// of the blog page to the directory of the html content files.</param>
        public Blog(Page page, string relativePath)
        {
            string fullPath = page.Server.MapPath(relativePath);

            DirectoryInfo info = new DirectoryInfo(fullPath);

            FileInfo[] files = info.GetFiles("*.htm*");
            int n = files.Length;

            if (n > 0)
            {
                Array.Sort<FileInfo>(files, CompareEarliestTimes.Comparer);
            }

            items = new BlogItem[n];

            for (int i = 0; i < n; i++)
                items[i] = new BlogItem(files[i]);
        }
예제 #5
0
파일: Blog.cs 프로젝트: rewanth21/freetime
        /// <summary>
        /// Returns a copy of the internal array of BlogItem objects
        /// to be manipulated as desired by the caller.
        /// 
        /// The items are in order of the earliest date of the html
        /// content files.
        /// </summary>
        public BlogItem[] GetBlogItems()
        {
            int n = items.Length;

            BlogItem[] copy = new BlogItem[n];

            for (int i = 0; i < n; i++)
                copy[i] = items[i];

            return copy;
        }