コード例 #1
0
    /*==========================================================================================================================
    | CONSTRUCTOR
    \-------------------------------------------------------------------------------------------------------------------------*/
    /// <summary>
    ///   Initializes a new instance of <see cref="TopicViewEngine"/>.
    /// </summary>
    /// <remarks>
    ///   When instantiated, the <see cref="TopicViewEngine.TopicViewEngine"/> constructor will initialize location formats with
    ///   extensions intended to support organizing views by <see cref="Topic.ContentType"/>.
    /// </remarks>
    public TopicViewEngine(IViewPageActivator viewPageActivator = null) : base(viewPageActivator) {

      /*------------------------------------------------------------------------------------------------------------------------
      | Define view location
      >-------------------------------------------------------------------------------------------------------------------------
      | Supports the following replacement tokens: {0} Controller, {1} View, {2} Area, and {3} Content Type.
      \-----------------------------------------------------------------------------------------------------------------------*/
      var viewLocations = new[] {
        "~/Views/{3}/{1}.cshtml",
        "~/Views/ContentTypes/{3}.{1}.cshtml",
        "~/Views/ContentTypes/{1}.cshtml",
        "~/Views/Shared/{1}.cshtml",
      };

      /*------------------------------------------------------------------------------------------------------------------------
      | Set view locations
      \-----------------------------------------------------------------------------------------------------------------------*/
      ViewLocationFormats = ViewLocationFormats.Union(viewLocations).ToArray();
      MasterLocationFormats = MasterLocationFormats.Union(viewLocations).ToArray();
      PartialViewLocationFormats = PartialViewLocationFormats.Union(viewLocations).ToArray();

      /*------------------------------------------------------------------------------------------------------------------------
      | Update view locations for areas
      \-----------------------------------------------------------------------------------------------------------------------*/
      viewLocations = viewLocations.Select(v => v.Replace("~", "~/{2}/")).ToArray();

      /*------------------------------------------------------------------------------------------------------------------------
      | Set area view locations
      \-----------------------------------------------------------------------------------------------------------------------*/
      AreaViewLocationFormats = AreaViewLocationFormats.Union(viewLocations).ToArray();
      AreaMasterLocationFormats = AreaMasterLocationFormats.Union(viewLocations).ToArray();
      AreaPartialViewLocationFormats = AreaPartialViewLocationFormats.Union(viewLocations).ToArray();

    }
コード例 #2
0
        private void Initialize()
        {
            MasterLocationFormats      = MasterLocationFormats.CSharpHtmlOnly();
            ViewLocationFormats        = ViewLocationFormats.CSharpHtmlOnly();
            PartialViewLocationFormats = PartialViewLocationFormats.CSharpHtmlOnly();

            AreaMasterLocationFormats      = AreaMasterLocationFormats.CSharpHtmlOnly();
            AreaPartialViewLocationFormats = AreaPartialViewLocationFormats.CSharpHtmlOnly();
            AreaViewLocationFormats        = AreaViewLocationFormats.CSharpHtmlOnly();
        }
コード例 #3
0
 public CsRazorViewEngine(IViewPageActivator viewPageActivator)
     : base(viewPageActivator)
 {
     AreaViewLocationFormats        = AreaViewLocationFormats.Where(f => f.EndsWith("cshtml")).ToArray();
     AreaMasterLocationFormats      = AreaMasterLocationFormats.Where(f => f.EndsWith("cshtml")).ToArray();
     AreaPartialViewLocationFormats = AreaPartialViewLocationFormats.Where(f => f.EndsWith("cshtml")).ToArray();
     ViewLocationFormats            = ViewLocationFormats.Where(f => f.EndsWith("cshtml")).ToArray();
     MasterLocationFormats          = MasterLocationFormats.Where(f => f.EndsWith("cshtml")).ToArray();
     PartialViewLocationFormats     = PartialViewLocationFormats.Where(f => f.EndsWith("cshtml")).ToArray();
     FileExtensions = FileExtensions.Where(f => f.EndsWith("cshtml")).ToArray();
 }
コード例 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Employment.Web.Mvc.Infrastructure.ViewEngines.CsRazorViewEngine" /> class.
        /// </summary>
        public CsRazorViewEngine()
        {
            const string extension = "cshtml";

            // Only include the cshtml type in location formats and file extensions
            AreaViewLocationFormats        = AreaViewLocationFormats.Where(s => s.EndsWith(extension, StringComparison.Ordinal)).ToArray();
            AreaMasterLocationFormats      = AreaMasterLocationFormats.Where(s => s.EndsWith(extension, StringComparison.Ordinal)).ToArray();
            AreaPartialViewLocationFormats = AreaPartialViewLocationFormats.Where(s => s.EndsWith(extension, StringComparison.Ordinal)).ToArray();
            ViewLocationFormats            = ViewLocationFormats.Where(s => s.EndsWith(extension, StringComparison.Ordinal)).ToArray();
            MasterLocationFormats          = MasterLocationFormats.Where(s => s.EndsWith(extension, StringComparison.Ordinal)).ToArray();
            PartialViewLocationFormats     = PartialViewLocationFormats.Where(s => s.EndsWith(extension, StringComparison.Ordinal)).ToArray();
            FileExtensions = FileExtensions.Where(s => s.EndsWith(extension, StringComparison.Ordinal)).ToArray();
        }