Hidistro.UI.Common.Controls/PageTitle.cs

(完整代码) 1KB

namespace Hidistro.UI.Common.Controls
{
    using Hidistro.Core;
    using Hidistro.Entities.Members;
    using Hidistro.SaleSystem.Vshop;
    using System;
    using System.Globalization;
    using System.Web;
    using System.Web.UI;

    [ParseChildren(false), PersistChildren(true)]
    public class PageTitle : Control
    {
        private const string titleKey = "Hishop.Title.Value";

        public static void AddSiteNameTitle(string title)
        {
            string siteName = SettingsManager.GetMasterSettings(true).SiteName;
            HttpCookie cookie = HttpContext.Current.Request.Cookies["Vshop-ReferralId"];
            if ((cookie != null) && !string.IsNullOrEmpty(cookie.Value))
            {
                DistributorsInfo distributorInfo = DistributorsBrower.GetDistributorInfo(Convert.ToInt32(cookie.Value));
                if (distributorInfo != null)
                {
                    siteName = distributorInfo.StoreName;
                }
            }
            AddTitle(string.Format(CultureInfo.InvariantCulture, "{0} - {1}", new object[] { title, siteName }));
        }

        public static void AddTitle(string title)
        {
            if (HttpContext.Current == null)
            {
                throw new ArgumentNullException("context");
            }
            HttpContext.Current.Items["Hishop.Title.Value"] = title;
        }

        protected override void Render(HtmlTextWriter writer)
        {
            string siteName = this.Context.Items["Hishop.Title.Value"] as string;
            if (string.IsNullOrEmpty(siteName))
            {
                siteName = SettingsManager.GetMasterSettings(true).SiteName;
            }
            writer.WriteLine("<title>{0}</title>", siteName);
        }
    }
}

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。