Exemple #1
0
        /// <summary>
        /// Gets all tags
        /// </summary>
        /// <returns></returns>
        public TagCollection GetAllTags()
        {
            TagCollection tc = ZCache.Get <TagCollection>("AllTags");

            if (tc == null)
            {
                tc = new TagCollection();

                TagCollection temp = TagCollection.FetchAll();

                foreach (Tag t in temp)
                {
                    Tag tag = tc.Find(
                        delegate(Tag tempTag)
                    {
                        return(tempTag.Name == t.Name);
                    });

                    if (tag == null)
                    {
                        tc.Add(t);
                    }
                }

                ZCache.InsertCache("AllTags", tc, 90);
            }

            return(tc);
        }
Exemple #2
0
        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            _tagsList      = new HtmlInputHidden();
            _tagsList.Name = "alltags";
            _tagsList.ID   = "alltags";

            StringBuilder             tagList      = new StringBuilder();
            Dictionary <string, bool> renderedTags = new Dictionary <string, bool>();

            foreach (Tag tag in TagCollection.FetchAll())
            {
                if (!renderedTags.ContainsKey(tag.Name))
                {
                    if (tagList.Length > 0)
                    {
                        tagList.Append("&");
                    }

                    tagList.Append(HttpUtility.UrlEncode(HttpUtility.HtmlDecode(tag.Name)));
                    tagList.Append("&");
                    tagList.Append(HttpUtility.UrlEncode(tag.Name));

                    renderedTags[tag.Name] = true;
                }
            }
            _tagsList.Value = tagList.ToString();

            this.Controls.Add(_tagsList);

            this.EnsureID();
        }