当前位置: 首页>>代码示例>>C#>>正文


C# TagList.Sort方法代码示例

本文整理汇总了C#中TagList.Sort方法的典型用法代码示例。如果您正苦于以下问题:C# TagList.Sort方法的具体用法?C# TagList.Sort怎么用?C# TagList.Sort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TagList的用法示例。


在下文中一共展示了TagList.Sort方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            //LabelMain.Text = GetContent("Body");

            LiteralPageTitle.Text = FormatPageTitle("Sermon Archive");

            LabelRightSideBarArea.Text = "<span class=\"title\">Archives</span><br />";

            TagList pageTagList = null;
            List<Document> SideBarList = null;
            List<Document> DocumentList = null;

            if (null == Session["EditRiverValleyMedia"])
            {
                DocumentList = Cache.Get("cache.RiverValley.MultimediaFiles") as List<Document>;
                SideBarList = Cache.Get("cache.RiverValley.MultimediaSideBar") as List<Document>;
                pageTagList = Cache.Get("cache.RiverValley.MultimediaTagList") as TagList;
            }

            if ((null == DocumentList) ||
                (null == SideBarList) ||
                (null == pageTagList))
            {//Means that there is no cache read everything from disk

                #region ReadLoop

                DocumentList = new List<Document>();
                SideBarList = new List<Document>();
                pageTagList = new TagList();

                DirectoryInfo directoryInfo = new DirectoryInfo(Server.MapPath(Document.MULTIMEDIA_FOLDER));

                List<FileInfo> multimediaFileList = new List<FileInfo>();

                multimediaFileList.AddRange(directoryInfo.GetFiles("*.mp3"));
                multimediaFileList.AddRange(directoryInfo.GetFiles("*.wma"));
                multimediaFileList.AddRange(directoryInfo.GetFiles("*.aac"));
                multimediaFileList.AddRange(directoryInfo.GetFiles("*.ac3"));
                multimediaFileList.AddRange(directoryInfo.GetFiles("*.mp4"));
                multimediaFileList.AddRange(directoryInfo.GetFiles("*.wmv"));
                multimediaFileList.AddRange(directoryInfo.GetFiles("*.mpg"));

                Document doc;
                System.Collections.Hashtable ht2 = new System.Collections.Hashtable();

                foreach (FileInfo file in multimediaFileList)
                {
                    try
                    {
                        if ((file.Extension.ToLower() == ".mp4") || (file.Extension.ToLower() == ".wmv") || (file.Extension.ToLower() == ".mpg"))
                            doc = new VideoFile(this, file.Name);
                        else
                            doc = new AudioFile(this, file.Name);

                        foreach (Tag t in doc.Tags)
                        {
                            pageTagList.Add(t);
                        }

                        //doc.Link = Document.MULTIMEDIA_FOLDER + "/" + doc.Name;
                        doc.Link = doc.Name;

                    }
                    catch { continue; }

                    DocumentList.Add(doc);

                    #region Fill RightSideBar

                    if (null == SideBarList.Find(delegate(Document st) { return ((st.Dated.Year == doc.Dated.Year) && (st.Dated.Month == doc.Dated.Month)); }))
                    {
                        SideBarList.Add(doc);
                    }

                    #endregion
                }
                #endregion

                #region Sort
                //Sort by date - sort should always be done after all filters for performance
                DocumentList.Sort(delegate(Document f1, Document f2)
                {
                    return DateTime.Compare(f2.Dated, f1.Dated);
                });

                //Do the same for right side bar
                SideBarList.Sort(delegate(Document f1, Document f2)
                {
                    return DateTime.Compare(f2.Dated, f1.Dated);
                });

                //And left
                pageTagList.Sort(delegate(ListedTag t1, ListedTag t2)
                {
                    return t1.Name.CompareTo(t2.Name);
                });

                #endregion

                #region Insert Cache
//.........这里部分代码省略.........
开发者ID:judek,项目名称:RiverValley2,代码行数:101,代码来源:Multimedia.aspx.cs

示例2: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            LabelMain.Text = GetContent("Body");

            LabelRightSideBarArea.Text = "<span class=\"subtitle\">By Month</span><br />";

            TagList pageTagList = null;
            List<Document> SideBarList = null;
            List<Document> DocumentList = null;

            if (null == Session["EditjudekGallery"])
            {
                DocumentList = Cache.Get("cache.judek.MultimediaFiles") as List<Document>;
                SideBarList = Cache.Get("cache.judek.MultimediaSideBar") as List<Document>;
                pageTagList = Cache.Get("cache.judek.MultimediaTagList") as TagList;
            }

            if ((null == DocumentList) ||
                (null == SideBarList) ||
                (null == pageTagList))
            {//Means that there is no cache read everything from disk

                #region ReadLoop

                DocumentList = new List<Document>();
                SideBarList = new List<Document>();
                pageTagList = new TagList();

                DirectoryInfo directoryInfo = new DirectoryInfo(Server.MapPath(Document.MULTIMEDIA_FOLDER));

                List<FileInfo> multimediaFileList = new List<FileInfo>();

                multimediaFileList.AddRange(directoryInfo.GetFiles("*.mp3"));
                multimediaFileList.AddRange(directoryInfo.GetFiles("*.wma"));
                multimediaFileList.AddRange(directoryInfo.GetFiles("*.aac"));
                multimediaFileList.AddRange(directoryInfo.GetFiles("*.ac3"));
                multimediaFileList.AddRange(directoryInfo.GetFiles("*.mp4"));
                multimediaFileList.AddRange(directoryInfo.GetFiles("*.wmv"));
                multimediaFileList.AddRange(directoryInfo.GetFiles("*.mpg"));

                Document doc;
                System.Collections.Hashtable ht2 = new System.Collections.Hashtable();

                foreach (FileInfo file in multimediaFileList)
                {
                    try
                    {
                        if ((file.Extension.ToLower() == ".mp4") || (file.Extension.ToLower() == ".wmv") || (file.Extension.ToLower() == ".mpg"))
                            doc = new VideoFile(this, file.Name);
                        else
                            doc = new AudioFile(this, file.Name);

                        foreach (Tag t in doc.Tags)
                        {
                            pageTagList.Add(t);
                        }

                        //doc.Link = Document.MULTIMEDIA_FOLDER + "/" + doc.Name;
                        doc.Link = doc.Name;

                    }
                    catch { continue; }

                    DocumentList.Add(doc);

                    #region Fill RightSideBar

                    if (null == SideBarList.Find(delegate(Document st) { return ((st.Dated.Year == doc.Dated.Year) && (st.Dated.Month == doc.Dated.Month)); }))
                    {
                        SideBarList.Add(doc);
                    }

                    #endregion
                }
                #endregion

                #region Sort
                //Sort by date - sort should always be done after all filters for performance
                DocumentList.Sort(delegate(Document f1, Document f2)
                {
                    return DateTime.Compare(f2.Dated, f1.Dated);
                });

                //Do the same for right side bar
                SideBarList.Sort(delegate(Document f1, Document f2)
                {
                    return DateTime.Compare(f2.Dated, f1.Dated);
                });

                //And left
                pageTagList.Sort(delegate(ListedTag t1, ListedTag t2)
                {
                    return t1.Name.CompareTo(t2.Name);
                });

                #endregion

                #region Insert Cache
                //Fill the cache with newly read info.

//.........这里部分代码省略.........
开发者ID:judek,项目名称:judek,代码行数:101,代码来源:Multimedia.aspx.cs


注:本文中的TagList.Sort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。