本文整理汇总了C#中IAppBuilder.UseFunc方法的典型用法代码示例。如果您正苦于以下问题:C# IAppBuilder.UseFunc方法的具体用法?C# IAppBuilder.UseFunc怎么用?C# IAppBuilder.UseFunc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAppBuilder
的用法示例。
在下文中一共展示了IAppBuilder.UseFunc方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Configuration
public void Configuration(IAppBuilder builder)
{
builder.UseAlpha("a", "b");
builder.UseFunc(app => Alpha.Invoke(app, "a", "b"));
builder.UseFunc(Alpha.Invoke, "a", "b");
builder.Use(Beta.Invoke("a", "b"));
builder.UseFunc(Beta.Invoke, "a", "b");
builder.UseGamma("a", "b");
builder.Use(typeof(Gamma), "a", "b");
builder.UseType<Gamma>("a", "b");
builder.UseFunc<AppFunc>(app => new Gamma(app, "a", "b").Invoke);
builder.Use(typeof(Delta), "a", "b");
builder.UseType<Delta>("a", "b");
builder.UseFunc<AppFunc>(app => new Delta(app, "a", "b").Invoke);
builder.Run(this);
}
示例2: Configuration
public void Configuration(IAppBuilder app)
{
app.UseFunc(LogBefore);
app.UseShowExceptions();
app.UseStatic(".", new List<string> { "/favicon.ico", "/images", "/html", "/css" });
app.Run(WebApp.App(new GmcJobList()));
}
示例3: AttachToHttpApp
public override void AttachToHttpApp(IRobot robo, IAppBuilder app)
{
app.UseFunc(next => async environment => {
var req = new Request(environment);
TraceRequest(robo, req);
await next(environment);
TraceResponse(robo, req, new Response(environment));
});
}
示例4: Configuration
public void Configuration(IAppBuilder app)
{
var bootstrapper = new DefaultNancyBootstrapper();
app
.UseFunc(LogRequests) // defined below
.UseShowExceptions() // from Gate.Middleware package
.MapHubs("/signalr") // from SignalR.Server assembly
.RunNancy(bootstrapper); // from Gate.Adapters.Nancy package
}
示例5: HelloWorld
public void HelloWorld(IAppBuilder app)
{
app.UseFunc(_ => env =>
{
var output = (Stream)env["owin.ResponseBody"];
using (var writer = new StreamWriter(output))
{
writer.Write("Hello world!");
}
return TaskHelpers.Completed();
});
}
示例6: AnotherAlternative
public void AnotherAlternative(IAppBuilder builder)
{
Assembly.Load("Nancy.ViewEngines.Spark");
builder
.UseFunc<AppDelegate>(ShowExceptions.Middleware)
.UseType<ContentType>()
.Map("/wilson", Wilson.App())
.Map("/wilsonasync", Wilson.App(true))
.RunCascade(
DefaultPage.App(),
NancyAdapter.App());
}
示例7: TextHtmlAlpha
public void TextHtmlAlpha(IAppBuilder app)
{
app.UseFunc(next => env =>
{
var headers = (IDictionary<string, string[]>)env["owin.ResponseHeaders"];
var body = (Stream)env["owin.ResponseBody"];
headers["Content-Type"] = new string[] { "text/html" };
using (var writer = new StreamWriter(body))
{
writer.Write("<p>alpha</p>");
}
return TaskHelpers.Completed();
});
}
示例8: MapBuilder
public MapBuilder(IAppBuilder builder, Func<AppFunc, IDictionary<string, AppFunc>, AppFunc> mapper)
{
_map = new Dictionary<string, AppFunc>();
_mapper = mapper;
_builder = builder.UseFunc<AppFunc>(a => _mapper(a, _map));
}
示例9: Configuration
public void Configuration(IAppBuilder app)
{
#if DEBUG
app.UseErrorPage();
#endif
app.UseWelcomePage("/");
app.UseFunc(LoggingMiddleware);
#region /mordor
app.UseFunc(
next =>
async env =>
{
if (!string.Equals("/mordor", (string)env["owin.RequestPath"], StringComparison.Ordinal))
{
await next(env);
return;
}
using (var sw = new StreamWriter((Stream)env["owin.ResponseBody"]))
{
var content = string.Format("One does not simply {0} into Mordor.",
env["owin.RequestMethod"]);
var headers = (IDictionary<string, string[]>)env["owin.ResponseHeaders"];
headers["Content-Length"] = new[] { content.Length.ToString() };
headers["Content-Type"] = new[] { "text/plain" };
await sw.WriteAsync(content);
}
});
#endregion
#region /email
app.UseFunc(
next =>
async env =>
{
if (!string.Equals("/email", (string)env["owin.RequestPath"], StringComparison.Ordinal))
{
await next(env);
return;
}
using (var sw = new StreamWriter((Stream)env["owin.ResponseBody"]))
{
var content =
"<html><body><form action='http://localhost:23456/api/send' method='POST'><label>Subject: <input name='Subject' /></label><input type='Submit'></form></body></html>";
var headers = (IDictionary<string, string[]>)env["owin.ResponseHeaders"];
headers["Content-Length"] = new[] { content.Length.ToString() };
headers["Content-Type"] = new[] { "text/html" };
await sw.WriteAsync(content);
}
});
#endregion
app.UseFunc(EnvironmentEndpoint);
}
示例10: Custom
public static void Custom(IAppBuilder builder)
{
builder.UseFunc<AppDelegate>(App);
}