当前位置: 首页>>代码示例>>C#>>正文


C# IAppBuilder.UseFunc方法代码示例

本文整理汇总了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);
        }
开发者ID:edoc,项目名称:owin-hosting,代码行数:28,代码来源:Startup.cs

示例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()));
        }
开发者ID:karasek,项目名称:OWIN-Test-Samples,代码行数:8,代码来源:Startup.cs

示例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));
     });
 }
开发者ID:anurse,项目名称:NuBot,代码行数:9,代码来源:HttpTracer.cs

示例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
        }
开发者ID:loudej,项目名称:owin-samples,代码行数:10,代码来源:Startup.cs

示例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();
     });
 }
开发者ID:tkggand,项目名称:katana,代码行数:12,代码来源:TestBaseWorks.cs

示例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());
        }
开发者ID:dragan,项目名称:gate,代码行数:13,代码来源:Startup.cs

示例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();
            });
        }
开发者ID:tkggand,项目名称:katana,代码行数:17,代码来源:SimpleGetTests.cs

示例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));
 }
开发者ID:virajs,项目名称:firefly,代码行数:6,代码来源:MapBuilder.cs

示例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);
        }
开发者ID:dahlbyk,项目名称:Presentations,代码行数:64,代码来源:Startup.cs

示例10: Custom

 public static void Custom(IAppBuilder builder)
 {
     builder.UseFunc<AppDelegate>(App);
 }
开发者ID:dragan,项目名称:gate,代码行数:4,代码来源:Startup.cs


注:本文中的IAppBuilder.UseFunc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。