public static string GetTitle(SeoHelper seoHelper)
        {
            if (seoHelper == null)
            {
                throw new ArgumentNullException(nameof(seoHelper));
            }

            bool isBaseTitleSet = !string.IsNullOrWhiteSpace(seoHelper.BaseTitle);
            bool isPageTitleSet = !string.IsNullOrWhiteSpace(seoHelper.Title);

            if (isBaseTitleSet && isPageTitleSet)
            {
                string titleFormat = !string.IsNullOrWhiteSpace(seoHelper.TitleFormat)
                                         ? seoHelper.TitleFormat
                                         : SeoHelper.DefaultTitleFormat;

                string title = string.Format(titleFormat, seoHelper.Title, seoHelper.BaseTitle);
                return(title);
            }

            if (!isBaseTitleSet)
            {
                return(!string.IsNullOrWhiteSpace(seoHelper.Title) ? seoHelper.Title : null);
            }

            return(!string.IsNullOrWhiteSpace(seoHelper.BaseTitle) ? seoHelper.BaseTitle : null);
        }
示例#2
0
        public static SeoHelper GetSeoHelper(this ViewDataDictionary viewData)
        {
            if (viewData == null)
            {
                throw new ArgumentNullException(nameof(viewData));
            }

            var seoHelperData = viewData[ViewDataKey] as SeoHelper;

            if (seoHelperData == null)
            {
                lock (viewData)
                {
                    seoHelperData = viewData[ViewDataKey] as SeoHelper;

                    if (seoHelperData == null)
                    {
                        seoHelperData = new SeoHelper();

                        viewData[ViewDataKey] = seoHelperData;
                    }
                }
            }

            return(seoHelperData);
        }
示例#3
0
        public override void OnHandleSeoValues(SeoHelper seoHelper)
        {
            if (seoHelper == null)
            {
                throw new ArgumentNullException(nameof(seoHelper));
            }

            seoHelper.BaseLinkCanonical = this.linkCanonical;
        }
示例#4
0
 public override void OnHandleSeoValues(SeoHelper seoHelper)
 {
     if (this.Append)
     {
         seoHelper.AddMetaKeyword(this.metaKeywords);
     }
     else
     {
         seoHelper.MetaKeywords = this.metaKeywords;
     }
 }
示例#5
0
        protected override void Initialize(RequestContext requestContext)
        {
            if (requestContext == null)
            {
                throw new ArgumentNullException(nameof(requestContext));
            }

            base.Initialize(requestContext);

            this.Seo = this.GetSeoHelper();
        }
        public override void OnHandleSeoValues(SeoHelper seoHelper)
        {
            if (seoHelper == null)
            {
                throw new ArgumentNullException(nameof(seoHelper));
            }

            base.OnHandleSeoValues(seoHelper);

            seoHelper.BaseTitle = this.title;
        }
        public override void OnHandleSeoValues(SeoHelper seoHelper)
        {
            if (seoHelper == null)
            {
                throw new ArgumentNullException(nameof(seoHelper));
            }

            if (!string.IsNullOrWhiteSpace(this.Format))
            {
                seoHelper.TitleFormat = this.Format;
            }
        }
示例#8
0
 public abstract void OnHandleSeoValues(SeoHelper seoHelper);
示例#9
0
 public override void OnHandleSeoValues(SeoHelper seoHelper)
 {
     seoHelper.MetaDescription = this.metaDescription;
 }
        public override void InitHelpers()
        {
            base.InitHelpers();

            this.Seo = this.GetSeoHelper();
        }
 public override void OnHandleSeoValues(SeoHelper seoHelper)
 {
     seoHelper.MetaRobotsIndex = this.robotsIndex;
 }
 public override void OnHandleSeoValues(SeoHelper seoHelper)
 {
     seoHelper.LinkCanonical = this.linkCanonical;
 }