protected override void ConfigureConventions(NancyConventions nancyConventions)
        {
            base.ConfigureConventions(nancyConventions);

            // By default, Nancy will serve static content from the 'Content' folder. We want to add 'Scripts' as well.
            nancyConventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("Scripts", "Scripts"));
        }
예제 #2
0
        protected override void ConfigureConventions(NancyConventions nancyConventions)
        {
            nancyConventions.StaticContentsConventions.Clear();
            nancyConventions.StaticContentsConventions.Add(AddStaticResourcePath("/resource", Assembly.GetAssembly(typeof(MainModule)), "VSMDemo.Host.Content.resource"));

            // static content
            nancyConventions.StaticContentsConventions.Add(Nancy.Conventions.StaticContentConventionBuilder.AddDirectory("scripts","Content/scripts"));
            nancyConventions.StaticContentsConventions.Add(Nancy.Conventions.StaticContentConventionBuilder.AddDirectory("content","Content"));

            // view location
            nancyConventions.ViewLocationConventions.Clear();
            nancyConventions.ViewLocationConventions.Add((viewName, model, context) =>
            {
                string module= context.ModulePath;
                if (string.IsNullOrEmpty(module))
                    module = context.ModuleName;

                string result = Path.Combine("Views", module.Trim('/', '\\'), viewName);
                if (!string.IsNullOrEmpty(result))
                    result = result.Replace(@"\", @"/");
                return result;
            });

            nancyConventions.ViewLocationConventions.Add((viewName, model, context) =>
            {
                string result = Path.Combine("Views", viewName);
                if (!string.IsNullOrEmpty(result))
                    result = result.Replace(@"\",@"/");
                return result;
            });
        }
        private static void ConfigureViewLocationConventions(NancyConventions conventions)
        {
            conventions.ViewLocationConventions = new List<Func<string, object, ViewLocationContext, string>>
            {
                (viewName, model, viewLocationContext) =>{
                    return string.IsNullOrEmpty(viewLocationContext.ModulePath) ? string.Empty : string.Concat("views/", viewLocationContext.ModulePath.TrimStart(new[] {'/'}), "/", viewName);
                },

                (viewName, model, viewLocationContext) => {
                    return string.Concat("views/", viewLocationContext.ModuleName, "/", viewName);
                },

                (viewName, model, viewLocationContext) =>{
                    return string.IsNullOrEmpty(viewLocationContext.ModulePath) ? string.Empty : string.Concat(viewLocationContext.ModulePath.TrimStart(new[] { '/' }), "/", viewName);
                },

                (viewName, model, viewLocationContext) => {
                    return string.Concat(viewLocationContext.ModuleName, "/", viewName);
                },

                (viewName, model, viewLocationContext) => {
                    return string.Concat("views/", viewName);
                },

                (viewName, model, viewLocationContext) => {
                    return viewName;
                },
            };
        }
예제 #4
0
        protected override void ConfigureConventions(NancyConventions nancyConventions)
        {
            base.ConfigureConventions(nancyConventions);

            ContentConventions.EmbeddedContent(nancyConventions);
            ContentConventions.StaticContent(nancyConventions);
        }
        protected override void ConfigureConventions(NancyConventions conventions)
        {
            base.ConfigureConventions(conventions);

            conventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("Scripts"));
            conventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("App"));
        }
예제 #6
0
        protected override void ConfigureConventions(NancyConventions nancyConventions)
        {
            Conventions.StaticContentsConventions.Clear();
            Conventions.StaticContentsConventions.AddDirectory("/", "app");

            base.ConfigureConventions(nancyConventions);
        }
예제 #7
0
파일: Bootstrapper.cs 프로젝트: nfink/Haven
 protected override void ConfigureConventions(NancyConventions nancyConventions)
 {
     nancyConventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("Fonts", @"Fonts"));
     nancyConventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("Scripts", @"Scripts"));
     nancyConventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("Uploads", @"Uploads"));
     base.ConfigureConventions(nancyConventions);
 }
        protected override void ConfigureConventions(NancyConventions nancyConventions)
        {
            base.ConfigureConventions(nancyConventions);

            Assembly assembly = Assembly.GetAssembly(typeof(AdministrationModule));
            var resourceNames = assembly.GetManifestResourceNames();
            var assemblyName = assembly.GetName().Name;

            nancyConventions.StaticContentsConventions.Add((context, path) =>
            {
                //get the embedded content from the assembly
                if (Path.GetDirectoryName(context.Request.Path) != null)
                {
                    var _path = assemblyName +
                                Path.GetDirectoryName(context.Request.Path)
                                    .Replace(Path.DirectorySeparatorChar, '.')
                                    .Replace("-", "_");
                    var _file = Path.GetFileName(context.Request.Path);
                    var _name = String.Concat(_path, ".", _file);
                    if (resourceNames.Contains(_name))
                    {
                        return new EmbeddedFileResponse(assembly, _path, _file);
                    }
                }
                return null;

            });
        }
 /// <summary>
 /// Initialise any conventions this class "owns".
 /// </summary>
 /// <param name="conventions">Convention object instance.</param>
 public void Initialise(NancyConventions conventions)
 {
     conventions.StaticContentsConventions = new List<Func<NancyContext, string, Response>>
     {
         StaticContentConventionBuilder.AddDirectory("Content")
     };
 }
예제 #10
0
		protected override void ConfigureConventions(NancyConventions conventions) {
			base.ConfigureConventions(conventions);

			conventions.StaticContentsConventions.AddDirectory("/App");
			conventions.StaticContentsConventions.AddDirectory("/Fonts");
			conventions.StaticContentsConventions.AddDirectory("/Scripts");
		}
예제 #11
0
        protected override void ConfigureConventions(NancyConventions nancyConventions)
        {
            nancyConventions.StaticContentsConventions.Add(Nancy.Embedded.Conventions.EmbeddedStaticContentConventionBuilder.AddDirectory("Static", GetType().Assembly));
            nancyConventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("Files", "Files", ".png"));

            base.ConfigureConventions(nancyConventions);
        }
예제 #12
0
 protected override void ConfigureConventions(NancyConventions nancyConventions)
 {
     base.ConfigureConventions(nancyConventions);
     nancyConventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("images"));
     nancyConventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("fonts"));
     nancyConventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("build"));
 }
예제 #13
0
 protected override void ConfigureConventions(NancyConventions nancyConventions)
 {
     base.ConfigureConventions(nancyConventions);
     nancyConventions.StaticContentsConventions.Clear();
     nancyConventions.StaticContentsConventions.Add
     (StaticContentConventionBuilder.AddDirectory("", "/SPA"));
 }
예제 #14
0
        protected override void ConfigureConventions(NancyConventions nancyConventions)
        {
            base.ConfigureConventions(nancyConventions);

              nancyConventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("docs", "docs"));
              nancyConventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("styles", "styles"));
        }
예제 #15
0
 protected override void ConfigureConventions(NancyConventions nancyConventions)
 {
     nancyConventions.StaticContentsConventions.Add(
         StaticContentConventionBuilder.AddDirectory("/assets")
     );
     base.ConfigureConventions(nancyConventions);
 }
 protected override void ConfigureConventions(NancyConventions nancyConventions)
 {
     base.ConfigureConventions(nancyConventions);
     nancyConventions.StaticContentsConventions.Add(
         StaticContentConventionBuilder.AddDirectory("assets"));
     Nancy.Json.JsonSettings.MaxJsonLength = Int32.MaxValue;
 }
예제 #17
0
 protected override void ConfigureConventions(NancyConventions nancyConventions)
 {
     Console.Write("Configuring server conventions... ");
     base.ConfigureConventions(nancyConventions);
     nancyConventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("static", "static"));
     Console.WriteLine("Done.");
 }
 protected override void ConfigureConventions(NancyConventions conventions)
 {
     conventions.ViewLocationConventions.Insert(0,
                                                (viewName, model, context) => string.Concat("Views/", viewName));
     conventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("Scripts"));
     base.ConfigureConventions(conventions);
 }
        protected override void ConfigureConventions(NancyConventions nc)
        {
            nc.ViewLocationConventions.Add((viewName, model, context) =>
            {
                string modulePath = context.ModulePath;

                if (!string.IsNullOrWhiteSpace(modulePath) || modulePath.StartsWith("/"))
                    modulePath = modulePath.Remove(0, 1);

                return string.Concat(modulePath, "/Views/", context.ModuleName, "/", viewName);
            });

            nc.ViewLocationConventions.Add((viewName, model, context) =>
            {
                string modulePath = context.ModulePath;

                if (!string.IsNullOrWhiteSpace(modulePath) || modulePath.StartsWith("/"))
                    modulePath = modulePath.Remove(0, 1);

                return string.Concat(modulePath, "/Views/Shared/", viewName);
            });

            nc.ViewLocationConventions.Add((viewName, model, context) => string.Concat("Public/Views/", context.ModuleName, "/", viewName));
            nc.ViewLocationConventions.Add((viewName, model, context) => string.Concat("Public/Views/Shared/", viewName));
        }
        protected override void ConfigureConventions(NancyConventions conventions)
        {
            base.ConfigureConventions(conventions);

              conventions.StaticContentsConventions.Add((ctx, root) =>
              {
            string fileName;
            if (ctx.Request.Path == "/vendor.js")
            {
              //return compressed version of vendor.js (as vendor.js.gz)
              fileName = Path.GetFullPath(Path.Combine(root, "Content", "vendor.js.gz"));
              if (File.Exists(fileName))
              {
            var response = new GenericFileResponse(fileName, ctx);
            response.Headers.Add("Content-Encoding", "gzip");
            response.Headers.Add("Content-Type", "application/javascript");
            return response;
              }
            }
            fileName = Path.GetFullPath(Path.Combine(root, "Content", (ctx.Request.Path == "/")?"index.html": ctx.Request.Path.Substring(1)));
            if (File.Exists(fileName))
            {
              return new GenericFileResponse(fileName, ctx);
            }
            return null;
              });
        }
예제 #21
0
 protected override void ConfigureConventions(NancyConventions conventions)
 {
     base.ConfigureConventions(conventions);
     
     conventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("", "dist"));
     conventions.ViewLocationConventions.Add((viewName, model, context) => string.Concat("dist/", viewName));
 }
        protected override void ConfigureConventions(NancyConventions nancyConventions)
        {
            base.ConfigureConventions(nancyConventions);

            Conventions.StaticContentsConventions.Add(
                StaticContentConventionBuilder.AddDirectory(@"C:\Projects\BuildServer\BuildServer\Services\Web\images", "images"));
        }
예제 #23
0
        protected override void ConfigureConventions(NancyConventions nancyConventions)
        {
            base.ConfigureConventions(nancyConventions);
            nancyConventions.StaticContentsConventions.Clear();

            nancyConventions.StaticContentsConventions.AddDirectory("Statics", "Statics");
        }
        protected override void ConfigureConventions(NancyConventions conventions)
        {
            base.ConfigureConventions(conventions);

            conventions.StaticContentsConventions.Clear();
            conventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("/lib", "/app/lib"));
            conventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("/js", "/app/js"));
            conventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("/css", "/app/css"));
            conventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("/img", "/app/img"));
            conventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("/fonts", "/app/fonts"));
            conventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("/partials", "/app/partials"));
            conventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddFile("/NoIE.html", "/app/NoIE.html"));
            conventions.StaticContentsConventions.Add((ctx, root) =>
            {
                var reqPath = ctx.Request.Path;

                if (!reqPath.Equals("/"))
                {
                    return null;
                }

                var fileName = Path.GetFullPath(Path.Combine(root, "app/index.html"));

                return new GenericFileResponse(fileName, ctx);
            });
        }
예제 #25
0
 protected override void ConfigureConventions(NancyConventions nancyConventions)
 {
     nancyConventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("/Scripts", "Scripts"));
     nancyConventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("/admin/Content", "/Areas/Admin/Content"));
     nancyConventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("/admin/Scripts", "/Areas/Admin/Scripts"));
     base.ConfigureConventions(nancyConventions);
 }
예제 #26
0
 protected override void ConfigureConventions(NancyConventions conventions)
 {
     conventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("css", @"Content/css"));
     conventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("js", @"Content/js"));
     conventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("img", @"Content/img"));
     base.ConfigureConventions(conventions);
 }
예제 #27
0
 protected override void ConfigureConventions(NancyConventions nancyConventions)
 {
     nancyConventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("content"));
     nancyConventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("scripts"));
     nancyConventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("viewModels"));
     base.ConfigureConventions(nancyConventions);
 }
예제 #28
0
        protected override void ConfigureConventions(Nancy.Conventions.NancyConventions nancyConventions)
        {
            base.ConfigureConventions(nancyConventions);

            nancyConventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("/Scripts"));
            nancyConventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("/partials"));
        }
        private static void ConfigureViewLocationConventions(NancyConventions conventions)
        {
            conventions.ViewLocationConventions = new List<Func<string, object, ViewLocationContext, string>>
            {
                (viewName, model, viewLocationContext) => {
                    return viewName;
                },

                (viewName, model, viewLocationContext) => {
                    return string.Concat("views/", viewName);
                },

                (viewName, model, viewLocationContext) => {
                    return string.Concat("views/", viewLocationContext.ModulePath, "/", viewName);
                },

                (viewName, model, viewLocationContext) => {
                    return string.Concat(viewLocationContext.ModulePath, "/", viewName);
                },

                (viewName, model, viewLocationContext) => {
                    return string.Concat("views/", viewLocationContext.ModuleName, "/", viewName);
                },

                (viewName, model, viewLocationContext) => {
                    return string.Concat(viewLocationContext.ModuleName, "/", viewName);
                }
            };
        }
예제 #30
0
 protected override void ConfigureConventions(NancyConventions nancyConventions)
 {
     base.ConfigureConventions(nancyConventions);
     if (ConfigurationManager.AppSettings["Environment"] == "Debug") {
         nancyConventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddFile("/style2.css", "bin/style2.css"));
     }
 }
예제 #31
0
 protected override void ConfigureConventions(NancyConventions nancyConventions)
 {
     // nancyConventions.StaticContentsConventions.Add(
     //     StaticContentConventionBuilder.AddDirectory((new TmxServerRootPathProvider()).GetRootPath(), "Root"));
     
     nancyConventions.StaticContentsConventions.Add(
         StaticContentConventionBuilder.AddDirectory((new TmxServerRootPathProvider()).GetRootPath() + @"Views/results", "results"));
     
     nancyConventions.StaticContentsConventions.Add(
         StaticContentConventionBuilder.AddDirectory((new TmxServerRootPathProvider()).GetRootPath() + "Views/Scripts", @"Scripts", ".js"));
         
     nancyConventions.StaticContentsConventions.Add(
         StaticContentConventionBuilder.AddDirectory((new TmxServerRootPathProvider()).GetRootPath() + "Views/settings", @"settings"));
         
     nancyConventions.StaticContentsConventions.Add(
         StaticContentConventionBuilder.AddDirectory((new TmxServerRootPathProvider()).GetRootPath() + "Views/status", @"status"));
     
     nancyConventions.StaticContentsConventions.Add(
         StaticContentConventionBuilder.AddDirectory((new TmxServerRootPathProvider()).GetRootPath() + "Views/testRuns", @"testRuns"));
     
     nancyConventions.StaticContentsConventions.Add(
         StaticContentConventionBuilder.AddDirectory((new TmxServerRootPathProvider()).GetRootPath() + "Views/workflows", @"workflows"));
     
     base.ConfigureConventions(nancyConventions);
 }
예제 #32
0
 protected override void ConfigureConventions(Nancy.Conventions.NancyConventions nancyConventions)
 {
     base.ConfigureConventions(nancyConventions);
     nancyConventions.StaticContentsConventions.Clear();
     nancyConventions.StaticContentsConventions.Add(
         StaticContentConventionBuilder.AddDirectory("static", @"static/")
         );
 }
예제 #33
0
        protected override void ConfigureConventions(Nancy.Conventions.NancyConventions nancyConventions)
        {
            //define where static content (js, css, img) are located
            nancyConventions.StaticContentsConventions.Add(
                StaticContentConventionBuilder.AddDirectory("static", "static"));

            base.ConfigureConventions(nancyConventions);
        }
 protected override void ConfigureConventions(Nancy.Conventions.NancyConventions nancyConventions)
 {
     nancyConventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("scripts", "scripts"));
     nancyConventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("Content", "Content"));
     nancyConventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("fonts", "fonts"));
     nancyConventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("Pages", "Pages"));
     base.ConfigureConventions(nancyConventions);
 }
예제 #35
0
        protected override void ConfigureConventions(Nancy.Conventions.NancyConventions nancyConventions)
        {
            base.ConfigureConventions(nancyConventions);

            Conventions.StaticContentsConventions.Add(
                StaticContentConventionBuilder.AddDirectory("/", "/Web")
                );
        }
 protected override void ConfigureConventions(Nancy.Conventions.NancyConventions nancyConventions)
 {
     nancyConventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("/", @"Web\"));
     nancyConventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("/Styles", @"Web\styles"));
     nancyConventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("/jspm_packages", @"Web\jspm_packages"));
     nancyConventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("/dist", @"Web\dist"));
     base.ConfigureConventions(nancyConventions);
 }
예제 #37
0
        /// <summary>
        /// 静的コンテンツの読み込み先
        /// </summary>
        /// <param name="nancyConventions"></param>
        protected override void ConfigureConventions(Nancy.Conventions.NancyConventions nancyConventions)
        {
            base.ConfigureConventions(nancyConventions);

            nancyConventions.StaticContentsConventions.AddDirectory("css", @"content/css");
            nancyConventions.StaticContentsConventions.AddDirectory("fonts", @"content/fonts");
            nancyConventions.StaticContentsConventions.AddDirectory("js", @"content/js");
            nancyConventions.StaticContentsConventions.AddDirectory("img", @"content/img");
        }
예제 #38
0
        protected override void ConfigureConventions(Nancy.Conventions.NancyConventions nancyConventions)
        {
            base.ConfigureConventions(nancyConventions);

            nancyConventions.ViewLocationConventions.Add(
                (viewName, model, context) => string.Concat("Web/views/", viewName));

            nancyConventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("js", "Web/js"));
            nancyConventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("assets", "Web/assets"));
            nancyConventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("fonts", "Web/fonts"));
            nancyConventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("css", "Web/css"));
        }
예제 #39
0
        protected override void ConfigureConventions(Nancy.Conventions.NancyConventions nancyConventions)
        {
            base.ConfigureConventions(nancyConventions);

            nancyConventions.StaticContentsConventions.Add(
                StaticContentConventionBuilder.AddFile("/robots.txt", "/Content/robots.txt")
                );

            nancyConventions.StaticContentsConventions.Add(
                StaticContentConventionBuilder.AddDirectory("static", @"/Content/")
                );
        }
예제 #40
0
        // The bootstrapper enables you to reconfigure the composition of the framework,
        // by overriding the various methods and properties.
        // For more information https://github.com/NancyFx/Nancy/wiki/Bootstrapper

        protected override void ConfigureConventions(Nancy.Conventions.NancyConventions nancyConventions)
        {
            base.ConfigureConventions(nancyConventions);

            // serve static content outside the default /Content folder (for Aurelia)
            nancyConventions.StaticContentsConventions.Add(
                StaticContentConventionBuilder.AddDirectory("dist", @"dist"));

            nancyConventions.StaticContentsConventions.Add(
                StaticContentConventionBuilder.AddDirectory("Views", @"Views"));

            nancyConventions.StaticContentsConventions.Add(
                StaticContentConventionBuilder.AddDirectory("test", @"test"));

            nancyConventions.StaticContentsConventions.Add(
                StaticContentConventionBuilder.AddDirectory("node_modules", @"node_modules"));

            nancyConventions.StaticContentsConventions.Add(
                StaticContentConventionBuilder.AddFile("/config.js", @"config.js"));
        }
예제 #41
0
 protected override void ConfigureConventions(Nancy.Conventions.NancyConventions nancyConventions)
 {
     nancyConventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("Scripts", "Scripts"));
     nancyConventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("img", "img"));
     base.ConfigureConventions(nancyConventions);
 }
예제 #42
0
 /// <summary>
 /// Extension method for NancyConventions
 ///
 /// conventions.MapStaticContent((File, Directory) =>
 /// {
 ///     File["/page.js"] = "page.js";
 ///     Directory["/images"] = "images";
 /// });
 /// </summary>
 /// <param name="staticConventions">The callback method allows you to describe the static content</param>
 public static void MapStaticContent(this NancyConventions conventions, Action <StaticFileContent, StaticDirectoryContent> staticConventions)
 {
     staticConventions(new StaticFileContent(conventions), new StaticDirectoryContent(conventions));
 }
예제 #43
0
 protected override void ConfigureConventions(Nancy.Conventions.NancyConventions nancyConventions)
 {
     nancyConventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("ui", @"ui"));
 }
예제 #44
0
 /// <summary>
 /// Initialise culture conventions
 /// </summary>
 /// <param name="conventions"></param>
 public void Initialise(NancyConventions conventions)
 {
     ConfigureDefaultConventions(conventions);
 }
        private static void ConfigureViewLocationConventions(NancyConventions conventions)
        {
            conventions.ViewLocationConventions = new List <Func <string, object, ViewLocationContext, string> >
            {
                (viewName, model, viewLocationContext) => {
                    if (string.IsNullOrEmpty(viewLocationContext.ModulePath))
                    {
                        return(string.Empty);
                    }

                    var path = viewLocationContext.ModulePath.TrimStart(new[] { '/' });

                    return(string.Concat("views/", path, "/", viewLocationContext.ModuleName, "/", viewName, "-", viewLocationContext.Context.Culture));
                },

                // 0 Handles: views / *modulepath* / *modulename* / *viewname*
                (viewName, model, viewLocationContext) => {
                    if (string.IsNullOrEmpty(viewLocationContext.ModulePath))
                    {
                        return(string.Empty);
                    }

                    var path = viewLocationContext.ModulePath.TrimStart(new[] { '/' });

                    return(string.Concat("views/", path, "/", viewLocationContext.ModuleName, "/", viewName));
                },

                (viewName, model, viewLocationContext) => {
                    if (string.IsNullOrEmpty(viewLocationContext.ModulePath))
                    {
                        return(string.Empty);
                    }

                    var path = viewLocationContext.ModulePath.TrimStart(new[] { '/' });

                    return(string.Concat(path, "/", viewLocationContext.ModuleName, "/", viewName, "-", viewLocationContext.Context.Culture));
                },

                // 1 Handles: *modulepath* / *modulename* / *viewname*
                (viewName, model, viewLocationContext) => {
                    if (string.IsNullOrEmpty(viewLocationContext.ModulePath))
                    {
                        return(string.Empty);
                    }

                    var path = viewLocationContext.ModulePath.TrimStart(new[] { '/' });

                    return(string.Concat(path, "/", viewLocationContext.ModuleName, "/", viewName));
                },

                (viewName, model, viewLocationContext) => {
                    return(string.IsNullOrEmpty(viewLocationContext.ModulePath) ? string.Empty : string.Concat("views/", viewLocationContext.ModulePath.TrimStart(new[] { '/' }), "/", viewName, "-", viewLocationContext.Context.Culture));
                },

                // 2 Handles: views / *modulepath* / *viewname*
                (viewName, model, viewLocationContext) => {
                    return(string.IsNullOrEmpty(viewLocationContext.ModulePath) ? string.Empty : string.Concat("views/", viewLocationContext.ModulePath.TrimStart(new[] { '/' }), "/", viewName));
                },

                (viewName, model, viewLocationContext) => {
                    return(string.IsNullOrEmpty(viewLocationContext.ModulePath) ? string.Empty : string.Concat(viewLocationContext.ModulePath.TrimStart(new[] { '/' }), "/", viewName, "-", viewLocationContext.Context.Culture));
                },

                // 3 Handles: *modulepath* / *viewname*
                (viewName, model, viewLocationContext) => {
                    return(string.IsNullOrEmpty(viewLocationContext.ModulePath) ? string.Empty : string.Concat(viewLocationContext.ModulePath.TrimStart(new[] { '/' }), "/", viewName));
                },

                (viewName, model, viewLocationContext) => {
                    return(string.Concat("views/", viewLocationContext.ModuleName, "/", viewName, "-", viewLocationContext.Context.Culture));
                },

                // 4 Handles: views / *modulename* / *viewname*
                (viewName, model, viewLocationContext) => {
                    return(string.Concat("views/", viewLocationContext.ModuleName, "/", viewName));
                },

                (viewName, model, viewLocationContext) => {
                    return(string.Concat(viewLocationContext.ModuleName, "/", viewName, "-", viewLocationContext.Context.Culture));
                },

                // 5 Handles: *modulename* / *viewname*
                (viewName, model, viewLocationContext) => {
                    return(string.Concat(viewLocationContext.ModuleName, "/", viewName));
                },

                (viewName, model, viewLocationContext) => {
                    return(string.Concat("views/", viewName, "-", viewLocationContext.Context.Culture));
                },

                // 6 Handles: views / *viewname*
                (viewName, model, viewLocationContext) => {
                    return(string.Concat("views/", viewName));
                },

                (viewName, model, viewLocationContext) => {
                    return(string.Concat(viewName, "-", viewLocationContext.Context.Culture));
                },

                // 7 Handles: *viewname*
                (viewName, model, viewLocationContext) => {
                    return(viewName);
                }
            };
        }
예제 #46
0
 /// <summary>
 /// Initialise any conventions this class "owns".
 /// </summary>
 /// <param name="conventions">Convention object instance.</param>
 public void Initialise(NancyConventions conventions)
 {
     ConfigureViewLocationConventions(conventions);
 }