示例#1
0
文件: Tag.cs 项目: sqzhuyi/cnopenblog
        /// <summary>
        /// 通过一个tags数组返回格式化后的Tag类数组
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        public static List<Tag> Format(List<string> list)
        {
            if (list.Count == 0) return new List<Tag>();

            list.Sort();

            List<Tag> tags = new List<Tag>();
            Tag tag = new Tag("");
            foreach (string s in list)
            {
                if (tag.Name.ToLower() != s.ToLower())
                {
                    if (tag.Name != null) tags.Add(tag);
                    tag = new Tag(s);
                }
                else
                {
                    tag.Count++;
                }
            }
            return tags;
        }