本文整理汇总了C#中Nancy.Conventions.NancyConventions类的典型用法代码示例。如果您正苦于以下问题:C# NancyConventions类的具体用法?C# NancyConventions怎么用?C# NancyConventions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NancyConventions类属于Nancy.Conventions命名空间,在下文中一共展示了NancyConventions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConfigureViewLocationConventions
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;
},
};
}
示例2: ConfigureConventions
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"));
}
示例3: ConfigureConventions
protected override void ConfigureConventions(NancyConventions conventions) {
base.ConfigureConventions(conventions);
conventions.StaticContentsConventions.AddDirectory("/App");
conventions.StaticContentsConventions.AddDirectory("/Fonts");
conventions.StaticContentsConventions.AddDirectory("/Scripts");
}
示例4: Initialise
/// <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")
};
}
示例5: ConfigureConventions
protected override void ConfigureConventions(NancyConventions nancyConventions)
{
base.ConfigureConventions(nancyConventions);
if (ConfigurationManager.AppSettings["Environment"] == "Debug") {
nancyConventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddFile("/style2.css", "bin/style2.css"));
}
}
示例6: ConfigureConventions
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);
}
示例7: ConfigureConventions
protected override void ConfigureConventions(NancyConventions conventions)
{
base.ConfigureConventions(conventions);
conventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("Scripts"));
conventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("App"));
}
示例8: ConfigureConventions
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);
}
示例9: ConfigureConventions
protected override void ConfigureConventions(NancyConventions nancyConventions)
{
nancyConventions.StaticContentsConventions.Add(
StaticContentConventionBuilder.AddDirectory("/assets")
);
base.ConfigureConventions(nancyConventions);
}
示例10: ConfigureConventions
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));
}
示例11: ConfigureConventions
protected override void ConfigureConventions(NancyConventions nancyConventions)
{
Console.Write("Configuring server conventions... ");
base.ConfigureConventions(nancyConventions);
nancyConventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("static", "static"));
Console.WriteLine("Done.");
}
示例12: ConfigureConventions
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;
});
}
示例13: ConfigureConventions
protected override void ConfigureConventions(NancyConventions nancyConventions)
{
base.ConfigureConventions(nancyConventions);
nancyConventions.StaticContentsConventions.Clear();
nancyConventions.StaticContentsConventions.AddDirectory("Statics", "Statics");
}
示例14: ConfigureConventions
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"));
}
示例15: ConfigureConventions
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);
}