• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# IPipelines类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IPipelines的典型用法代码示例。如果您正苦于以下问题:C# IPipelines类的具体用法?C# IPipelines怎么用?C# IPipelines使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IPipelines类属于命名空间,在下文中一共展示了IPipelines类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: RequestStartup

        protected override void RequestStartup(TinyIoCContainer container, IPipelines pipelines, NancyContext context)
        {
            var formsAuthConfiguration =
                new FormsAuthenticationConfiguration()
                {
                    RedirectUrl = "~/login",
                    UserMapper = container.Resolve<IUserMapper>(),
                };

            FormsAuthentication.Enable(pipelines, formsAuthConfiguration);
            CookieBasedSessions.Enable(pipelines);

            pipelines.BeforeRequest.AddItemToStartOfPipeline(ctx =>
                {
                    if (Helper.Settings.Instance.Client.CanConnect)
                        return null;
                    else
                    {
                        if (String.Compare(ctx.Request.Path, "/notavailable", true) == 0)
                        {
                            return null;
                        }
                        return new RedirectResponse("/notavailable");
                    }
                });

            base.RequestStartup(container, pipelines, context);
        }
开发者ID:ChrisK91,项目名称:CWSRestart,代码行数:28,代码来源:ApplicationBootstrapper.cs


示例2: Initialize

    public void Initialize(IPipelines pipelines)
    { 
      pipelines.BeforeRequest.AddItemToStartOfPipeline(RunCassetteHandler);
      pipelines.BeforeRequest.AddItemToStartOfPipeline(InitializeCassetteRequestState);

      pipelines.AfterRequest.AddItemToEndOfPipeline(RewriteResponseContents);
    }
开发者ID:thefringeninja,项目名称:Cassette.Nancy,代码行数:7,代码来源:CassetteStartup.cs


示例3: ApplicationStartup

        protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);

            // In reality you would use a pre-built authentication/claims provider
            pipelines.BeforeRequest += (ctx) =>
            {
                // World's-worse-authentication (TM)
                // Pull the username out of the querystring if it exists
                // and build claims from it
                var username = ctx.Request.Query.username;

                if (username.HasValue)
                {
                    ctx.CurrentUser = new DemoUserIdentity
                                          {
                                              UserName = username.ToString(),
                                              Claims = BuildClaims(username.ToString())
                                          };
                }

                return null;
            };

            pipelines.AfterRequest += (ctx) =>
            {
                // If status code comes back as Unauthorized then
                // forward the user to the login page
                if (ctx.Response.StatusCode == HttpStatusCode.Unauthorized)
                {
                    ctx.Response = new RedirectResponse("/login?returnUrl=" + Uri.EscapeDataString(ctx.Request.Path));
                }
            };
        }
开发者ID:Borzoo,项目名称:Nancy,代码行数:34,代码来源:AuthenticationBootstrapper.cs


示例4: RequestStartup

        protected override void RequestStartup(TinyIoCContainer container, IPipelines pipelines, NancyContext context)
        {
            var formsAuthConfig = new FormsAuthenticationConfiguration
            {
                RedirectUrl = "~/login",
                UserMapper = container.Resolve<IUserMapper>()
            };

            FormsAuthentication.Enable(pipelines, formsAuthConfig);

            pipelines.AfterRequest += ctx =>
            {
                var dbContext = container.Resolve<SmartFlowContext>();
                dbContext.SaveChanges();
            };

            pipelines.OnError += (ctx, ex) =>
            {
                var logger = container.Resolve<TextFileLogger>();
                logger.Write("Error", Enums.LogLevel.ApplicationError, ex);
                return ErrorResponse.FromException(ex);
            };

            base.RequestStartup(container, pipelines, context);
        }
开发者ID:DeanMcgarrigle,项目名称:SmartFlow,代码行数:25,代码来源:Bootstrapper.cs


示例5: Initialize

        /// <summary>
        /// Perform any initialisation tasks
        /// </summary>
        /// <param name="pipelines">Application pipelines</param>
        /// <param name="context">The current context</param>
        public void Initialize(IPipelines pipelines, NancyContext context)
        {
            // On each request, store the NancyContext in the LogicalCallContext
            CallContext.LogicalSetData(NancyConfiguration.NancyContextDataSlot, context);

            var nancyConfiguration = NancyConfiguration.Settings;
            if (nancyConfiguration == null)
                return;

            var name = nancyConfiguration.PipelineName.Value;
            var sharpRaven = new PipelineItem(name, (nancyContext, exception) =>
            {
                if (nancyConfiguration.CaptureExceptionOnError.Value)
                {
                    var guid = this.ravenClient.CaptureException(exception);

                    if (guid != null)
                    {
                        context.Items.Add(NancyConfiguration.SentryEventGuidKey, guid);
                        exception.Data.Add(NancyConfiguration.SentryEventGuidKey, guid);
                    }
                }

                return null;
            });

            pipelines.OnError.AddItemToStartOfPipeline(sharpRaven);
        }
开发者ID:getsentry,项目名称:raven-csharp,代码行数:33,代码来源:SentryRequestStartup.cs


示例6: ApplicationStartup

        protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {

            base.ApplicationStartup(container, pipelines);

            var configuration = new BasicAuthenticationConfiguration(container.Resolve<IUserValidator>(), "test-realm");
            BasicAuthentication.Enable(pipelines,configuration);

            var stateless = new StatelessAuthenticationConfiguration(c =>
            {
                const string key = "X-Auth-Token";
                string token = null;

                if (c.Request.Headers.Authorization == null || !c.Request.Headers.Authorization.Any())
                {
                    _log.ErrorFormat("No request headers are present in the request {0}", c);
                    return null;
                }

                if (c.Request.Headers.FirstOrDefault(f => f.Key == key).Value == null ||
                    string.IsNullOrEmpty(c.Request.Headers.FirstOrDefault(f => f.Key == key).Value.First()))
                {
                    _log.ErrorFormat("No Key present in the request headers");
                    return null;
                }

                token = c.Request.Headers.FirstOrDefault(f => f.Key == key).Value.First();
                _log.InfoFormat("Token used {0}", token);

                var user = container.Resolve<IUserApiMapper>();
                return user.GetUserFromToken(token);

            });
            StatelessAuthentication.Enable(pipelines, stateless);
        }
开发者ID:rjonker1,项目名称:lightstone-data-platform,代码行数:35,代码来源:Bootstrapper.cs


示例7: ApplicationStartup

 protected override void ApplicationStartup(TinyIoC.TinyIoCContainer container, IPipelines pipelines)
 {
     FormsAuthentication.Enable(pipelines, new FormsAuthenticationConfiguration {
         RedirectUrl = "~/login",
         UserMapper = _mocks[typeof(IUserRepository)] as IUserRepository
     });
 }
开发者ID:bobbles31,项目名称:Ideastrike,代码行数:7,代码来源:IdeaStrikeTestBootStrapper.cs


示例8: ApplicationStartup

        protected override void ApplicationStartup(ILifetimeScope container, IPipelines pipelines)
        {
            StaticConfiguration.DisableErrorTraces = false;

              // Enable memory sessions, and secure them against session hijacking
              pipelines.EnableInProcSessions();
              pipelines.BeforeRequest.AddItemToStartOfPipeline(ctx => {
            var antiSessionHijackLogic = container.Resolve<IAntiSessionHijackLogic>();
            return antiSessionHijackLogic.InterceptHijackedSession(ctx.Request);
              });
              pipelines.AfterRequest.AddItemToEndOfPipeline(ctx => {
            var antiSessionHijackLogic = container.Resolve<IAntiSessionHijackLogic>();
            antiSessionHijackLogic.ProtectResponseFromSessionHijacking(ctx);
              });

              // Load the user from the AspNet session. If one is found, create a Nancy identity and assign it.
              pipelines.BeforeRequest.AddItemToEndOfPipeline(ctx => {
            var identityAssigner = container.Resolve<INancyIdentityFromContextAssigner>();
            identityAssigner.AssignNancyIdentityFromContext(ctx);
            return null;
              });

              pipelines.OnError = pipelines.OnError
            + ErrorPipelines.HandleModelBindingException()
            + ErrorPipelines.HandleRequestValidationException()
            + ErrorPipelines.HandleSecurityException();

              base.ApplicationStartup(container, pipelines);
        }
开发者ID:DavidLievrouw,项目名称:InvoiceGen,代码行数:29,代码来源:Bootstrapper.cs


示例9: Enable

        /// <summary>
        /// Enables forms authentication for the application
        /// </summary>
        /// <param name="pipelines">Pipelines to add handlers to (usually "this")</param>
        /// <param name="configuration">Forms authentication configuration</param>
        public static void Enable(IPipelines pipelines, FormsAuthenticationConfiguration configuration)
        {
            if (pipelines == null)
            {
                throw new ArgumentNullException("pipelines");
            }

            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            if (!configuration.IsValid)
            {
                throw new ArgumentException("Configuration is invalid", "configuration");
            }

            currentConfiguration = configuration;

            pipelines.BeforeRequest.AddItemToStartOfPipeline(GetLoadAuthenticationHook(configuration));
            if (!configuration.DisableRedirect)
            {
                pipelines.AfterRequest.AddItemToEndOfPipeline(GetRedirectToLoginHook(configuration));
            }
        }
开发者ID:rahulchrty,项目名称:Nancy,代码行数:30,代码来源:FormsAuthentication.cs


示例10: ApplicationStartup

 // 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 ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
 {
     container.Register<IStorage, Storage>().AsSingleton();
     container.Register<CredentialsStorage>().AsSingleton();
     var serverScheduler = new ServerScheduler(container.Resolve<IStorage>());
     serverScheduler.Start();
 }
开发者ID:Stelmashenko-A,项目名称:CourseWork,代码行数:10,代码来源:Bootstrapper.cs


示例11: ApplicationStartup

        /// <summary>
        /// Applications the startup.
        /// </summary>
        /// <param name="container">The container.</param>
        /// <param name="pipelines">The pipelines.</param>
        protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);

            pipelines.BeforeRequest += ctx =>
            {
                var identity = (WindowsIdentity)HttpContext.Current.User.Identity;
                if (identity.IsAuthenticated)
                {
                    // Resolve<UserManager>
                    // Get from DB/Cache
                    // Add user to ICurrentUSerProvider
                    // Get Claims

                    ctx.CurrentUser = new DemoUserIdentity
                    {
                        UserName = identity.Name,
                        Claims = new[] { "Basic", "Finance" }
                    };
                }

                return null;
            };

            pipelines.AfterRequest += ctx =>
            {
                // If status code comes back as Unauthorized then
                // forward the user to the unauthorised page
                //if (ctx.Response.StatusCode == HttpStatusCode.Unauthorized
                //    || ctx.Response.StatusCode == HttpStatusCode.Forbidden)
                //{
                //    ctx.Response = new RedirectResponse("/Unauthorised");
                //}
            };
        }
开发者ID:caodaiming,项目名称:Snippets,代码行数:40,代码来源:CustomBootstrapper.cs


示例12: RequestStartup

        protected override void RequestStartup(IWindsorContainer container, IPipelines pipelines, NancyContext context)
        {
            //var formsAuthConfiguration = new FormsAuthenticationConfiguration
            //{
            //    RedirectUrl = "/login",
            //    UserMapper = container.Resolve<IUserMapper>(),
            //};
            //FormsAuthentication.Enable(pipelines, formsAuthConfiguration);

            pipelines.BeforeRequest.AddItemToEndOfPipeline(ctx =>
            {
                if (ctx.CurrentUser != null) ctx.ViewBag.UserName = ctx.CurrentUser.UserName;
                return null;
            });

            pipelines.BeforeRequest.AddItemToStartOfPipeline(nancyContext =>
            {
                //nancyContext.Request.Headers.UserAgent = "Lightstone";
                var token = "";
                var cookie = nancyContext.Request.Headers.Cookie.FirstOrDefault(x => (x.Name + "").ToLower() == "token");
                if (cookie != null)
                    token = HttpUtility.UrlDecode(cookie.Value);
                    //nancyContext.Request.Headers.Authorization = "Token {0}".FormatWith(HttpUtility.UrlDecode(token.Value));

                var user = container.Resolve<ITokenizer>().Detokenize(token, nancyContext, new DefaultUserIdentityResolver());
                if (user != null)
                    nancyContext.CurrentUser = user;
                return null;
            });
            TokenAuthentication.Enable(pipelines, new TokenAuthenticationConfiguration(container.Resolve<ITokenizer>()));
        }
开发者ID:rjonker1,项目名称:lightstone-data-platform,代码行数:31,代码来源:Bootstrapper.cs


示例13: ApplicationStartup

    protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
    {
      base.ApplicationStartup(container, pipelines);

      // Add an error handler to catch our entity not found exceptions
      pipelines.OnError += (context, exception) =>
      {
        // If we've raised an EntityNotFound exception in our data layer
        if (exception is EntityNotFoundException)
          return new Response()
          {
            StatusCode = HttpStatusCode.NotFound,
            ContentType = "text/html",
            Contents = (stream) =>
            {
              var errorMessage = Encoding.UTF8.GetBytes("A Data Entity with the requested ID was not found in the database.");
              stream.Write(errorMessage, 0, errorMessage.Length);
            }
          };

        // If none of the above handles our exception, then pass it on as a 500
        throw exception;
      };
      // End error handler

      CookieBasedSessions.Enable(pipelines);

    }
开发者ID:RickIsWright,项目名称:nancyfxbook,代码行数:28,代码来源:CustomBootstrapper.cs


示例14: RequestStartup

        protected override void RequestStartup(ILifetimeScope container, IPipelines pipelines, NancyContext context)
        {
            // No registrations should be performed in here, however you may
            // resolve things that are needed during request startup.

            FormsAuthentication.Enable(pipelines, new FormsAuthenticationConfiguration()
            {
                RedirectUrl = "~/account/login",
                UserMapper = container.Resolve<IUserMapper>(),
            });

            pipelines.BeforeRequest.AddItemToEndOfPipeline(c =>
            {
                if (c.CurrentUser.IsAuthenticated())
                {
                    container.Resolve<ITenantContext>().SetTenantId(c.CurrentUser.AsAuthenticatedUser().Id, c.CurrentUser.HasClaim("Admin"));
                    c.ViewBag.UserName = c.CurrentUser.AsAuthenticatedUser().FullName;
                    c.ViewBag.IsAdmin = c.CurrentUser.HasClaim("Admin");
                }
                else
                    container.Resolve<ITenantContext>().SetTenantId(null, false);

                return null;
            });
        }
开发者ID:kcornelis,项目名称:FreelanceManager.NET,代码行数:25,代码来源:NancyTestBootstrapper.cs


示例15: ApplicationStartup

        protected override void ApplicationStartup(ILifetimeScope container, IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);

            // register interfaces/implementations
            container.Update(builder => builder
                //.RegisterType<CouchDbTShirtRepository>()
                .RegisterType<MockedTShirtRepository>()
                .As<ITShirtRepository>());

            // register MyCouchStore parameter for couchdb repo classes
            container.Update(builder => builder
                .RegisterType<MyCouchStore>()
                .As<IMyCouchStore>()
                .UsingConstructor(typeof (string), typeof (string))
                .WithParameters(new [] {
                    new NamedParameter("dbUri","http://seraya_dba:[email protected]:5984/"),
                    new NamedParameter("dbName","cshirts")
                })
            );

            // TODO: remove after implementing REST-Api & replacing razor with angular
            // display razor error messages
            StaticConfiguration.DisableErrorTraces = false;
        }
开发者ID:takahser,项目名称:C-Shirts,代码行数:25,代码来源:Bootstrapper.cs


示例16: Initialize

 public void Initialize(IPipelines pipelines)
 {
     pipelines.OnError.AddItemToEndOfPipeline((ctx, ex) => {
         Debug.WriteLine($"Error on request {ex.Message}");
         return null;
     });
 }
开发者ID:AGRocks,项目名称:chezzles,代码行数:7,代码来源:ApplicationStartup.cs


示例17: Initialize

 /// <summary>
 /// Perform any initialisation tasks
 /// </summary>
 /// <param name="pipelines">Application pipelines</param>
 public void Initialize(IPipelines pipelines)
 {
     foreach (var viewEngine in viewEngines)
     {
         viewEngine.Initialize(CreateViewEngineStartupContext(viewEngine));
     }
 }
开发者ID:RadifMasud,项目名称:Nancy,代码行数:11,代码来源:ViewEngineApplicationStartup.cs


示例18: ApplicationStartup

        protected override void ApplicationStartup(ILifetimeScope container, IPipelines pipelines)
        {
            pipelines.OnError.AddItemToEndOfPipeline(LogException);
            pipelines.BeforeRequest.AddItemToEndOfPipeline(DetectLanguage);

            DoMigrations();
        }
开发者ID:shiftkey,项目名称:Ideastrike,代码行数:7,代码来源:IdeastrikeBootstrapper.cs


示例19: ApplicationStartup

        protected override void ApplicationStartup(ILifetimeScope container, IPipelines pipelines)
        {
            pipelines.OnError.AddItemToEndOfPipeline((context, exception) =>
                                                         {
                                                             var message = string.Format("Exception: {0}", exception);
                                                             new ElmahErrorHandler.LogEvent(message).Raise();
                                                             return null;
                                                         });

            pipelines.BeforeRequest.AddItemToEndOfPipeline(ctx =>
                                                               {
                                                                   var lang = ctx.Request.Headers.AcceptLanguage.FirstOrDefault();
                                                                   if (lang != null)
                                                                   {
                                                                       // Accepted language can be something like "fi-FI", but it can also can be like fi-FI,fi;q=0.9,en;q=0.8
                                                                       if (lang.Contains(","))
                                                                           lang = lang.Substring(0, lang.IndexOf(","));

                                                                       System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo(lang);
                                                                       System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo(lang);
                                                                   }
                                                                   return null;
                                                               });

            DoMigrations();
        }
开发者ID:meatherly,项目名称:Ideastrike,代码行数:26,代码来源:IdeastrikeBootstrapper.cs


示例20: ApplicationStartup

        protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);

            JsonSettings.RetainCasing = true;
            JsonSettings.MaxJsonLength = int.MaxValue;
            StaticConfiguration.CaseSensitive = false;

            var sessionManager = new SessionManager(new MemorySessionProvider("Encore", int.Parse(ConfigurationManager.AppSettings["Session.Timeout"])));
            sessionManager.Run(pipelines);

            pipelines.OnError.AddItemToEndOfPipeline((ctx, ex) =>
            {
                log.Error("Unhandled error on request: " + ctx.Request.Url, ex);

                ctx.Items["error"] = new Error
                {
                    ErrorMessage = "An unhandled error occurred",
                    StatusCode = HttpStatusCode.InternalServerError
                };

                return null;
            });

            ConfigureAutoMapper();
        }
开发者ID:alnya,项目名称:Encore-v2,代码行数:26,代码来源:Bootstrapper.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IPlace类代码示例发布时间:2022-05-24
下一篇:
C# IPipeline类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap