Example #1
0
        protected void RegisterViews()
        {
            var embeddedProvider = new EmbeddedViewFileProvider(new ExternalViewFixer());
            embeddedProvider.Add(new NamespaceMapping(typeof(Lib.Areas.Some.Controllers.MyController).Assembly, "BasicPlugins.Lib"));
            //GriffinVirtualPathProvider.Current.Add(embeddedProvider);

            var diskLocator = new DiskFileLocator();
            diskLocator.Add("~/", Path.GetFullPath(Server.MapPath("~/") + @"..\BasicPlugins.Lib\"));
            var viewProvider = new ViewFileProvider(diskLocator, new ExternalViewFixer());
            GriffinVirtualPathProvider.Current.Add(viewProvider);

            HostingEnvironment.RegisterVirtualPathProvider(GriffinVirtualPathProvider.Current);
        }
        /// <summary>
        /// Register the content files used by the adminstration area.
        /// </summary>
        /// <param name="provider"><c>GriffinVirtualPathProvider.Current</c></param>
        /// <param name="layoutVirtualPath">Typically <c>"~/Views/Shared/_Layout.cshtml"</c></param>
        public static void RegisterAdminFiles(this GriffinVirtualPathProvider provider, string layoutVirtualPath)
        {
            if (provider == null) throw new ArgumentNullException("provider");
            if (layoutVirtualPath == null) throw new ArgumentNullException("layoutVirtualPath");
            // you can assign a custom WebViewPage or a custom layout in EmbeddedViewFixer.
            var fixer = new ExternalViewFixer()
            {
                LayoutPath = layoutVirtualPath
            };

            var griffinAssembly = typeof(MvcContrib.Areas.Griffin.GriffinAreaRegistration).Assembly;

            // for view files
            var embeddedViews = new EmbeddedViewFileProvider(VirtualPathUtility.ToAbsolute("~/"), fixer);
            embeddedViews.Add(new NamespaceMapping(griffinAssembly, "Griffin.MvcContrib"));
            provider.Add(embeddedViews);
            
            // Add support for loading content files:
            var contentFilesProvider = new EmbeddedFileProvider(VirtualPathUtility.ToAbsolute("~/"));
            contentFilesProvider.Add(new NamespaceMapping(griffinAssembly, "Griffin.MvcContrib"));
            provider.Add(contentFilesProvider);

        }
        private static void AddSupportForEmbeddedViews()
        {
            // you can assign a custom WebViewPage or a custom layout in EmbeddedViewFixer.
            var fixer = new ExternalViewFixer();
            var provider = new EmbeddedViewFileProvider(VirtualPathUtility.ToAbsolute("~/"), fixer);
            provider.Add(new NamespaceMapping(typeof(MvcContrib.Areas.Griffin.GriffinAreaRegistration).Assembly, "Griffin.MvcContrib"));

            GriffinVirtualPathProvider.Current.Add(provider);
            HostingEnvironment.RegisterVirtualPathProvider(GriffinVirtualPathProvider.Current);
        }