csharp 灵感来自Heather Floyd的文章(http://24days.in/umbraco-cms/2016/unique-sites-using-theming),但是我们的用例略有不

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp 灵感来自Heather Floyd的文章(http://24days.in/umbraco-cms/2016/unique-sites-using-theming),但是我们的用例略有不相关的知识,希望对你有一定的参考价值。

using System.Web.Mvc;
using Umbraco.Core;
using Umbraco.Web.Mvc;

namespace Endzone.Umbraco.PatternLib
{

    /// <summary>
    /// Registers site specific Umbraco application event handlers
    /// </summary>
    public class UmbracoEvents : ApplicationEventHandler
    {

        protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            base.ApplicationStarting(umbracoApplication, applicationContext);
            
            /* 
            * Replace the Umbraco RenderViewEngine with our PatternLibRazorViewEngine
            * this allows us to add our own View locations without too many extra steps
            */
            IViewEngine remove = null;
            ViewEngines.Engines.ForEach(x => {
                if (x.GetType() == typeof(RenderViewEngine))
                    remove = x;
            });
            if (remove != null)
                ViewEngines.Engines.Remove(remove);

            ViewEngines.Engines.Add(new PatternLibRazorViewEngine());

        }

    }
}
using System.Linq;
using Umbraco.Web.Mvc;

namespace Endzone.Umbraco.PatternLib
{
    public class PatternLibRazorViewEngine : RenderViewEngine
    {
        public PatternLibRazorViewEngine() : base()
        {
           /* 
            * Default partials "patterns" folder, these can be overridden simply by placing a partial with the same name in "Views/Partials"
            */
            const string patternLibViewFolder = "~/Views/_patterns";


           /* 
            * Let Umbraco's RenderViewEngine do the work, just add our partials view location to the list...
            */
            var umbracoPartialViewlocations = PartialViewLocationFormats.ToList();
            var patternLibPartialViewLocations = umbracoPartialViewlocations.Select(x => x.Replace("~/Views", patternLibViewFolder) ).ToArray();
            umbracoPartialViewlocations.AddRange(patternLibPartialViewLocations);

            PartialViewLocationFormats = umbracoPartialViewlocations.ToArray();
        }
    }
}

以上是关于csharp 灵感来自Heather Floyd的文章(http://24days.in/umbraco-cms/2016/unique-sites-using-theming),但是我们的用例略有不的主要内容,如果未能解决你的问题,请参考以下文章

《Tormented Souls》上架Steam 灵感来自《生化》系列

css Page Alert热门Hello Bar灵感来自

“liftM”这个名字的灵感来自数学中的电梯吗? [关闭]

text 灵感来自https://gist.github.com/octocat/9257657

Noms:灵感来自Git的数据库

css 只是对Pinboard.in的修改,灵感来自Brett Terpstra。最适合OS X.