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;
 }
Пример #10
0
        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;
 }