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


C# Func.All方法代码示例

本文整理汇总了C#中Func.All方法的典型用法代码示例。如果您正苦于以下问题:C# Func.All方法的具体用法?C# Func.All怎么用?C# Func.All使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Func的用法示例。


在下文中一共展示了Func.All方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ValidateHandshakeResponseHeaders

        private void ValidateHandshakeResponseHeaders()
        {
            Func<bool>[] validators = new Func<bool>[]
            {
                () => this.ValidateHandshakeResponseHeader(
                    "upgrade",
                    v => v.Equals("websocket", StringComparison.OrdinalIgnoreCase),
                    new ProtocolViolationException("Server protocol violation. Server did not respond with an Upgrade header with 'WebSocket' value.")),
                () => this.ValidateHandshakeResponseHeader(
                    "connection",
                    v => v.Equals("upgrade, http2-icb", StringComparison.OrdinalIgnoreCase),
                    new ProtocolViolationException("Server protocol violation. Server did not respond with an Connection header with 'Upgrade' value.")),
                () => this.ValidateHandshakeResponseHeader(
                    "sec-websocket-accept",
                    this.ValidateAccept,
                    new ProtocolViolationException("Server protocol violation. Server did not respond with sec-websocket-accept header that matches the sec-websocket-accept header sent on request.")),
                () => string.IsNullOrEmpty(this.Protocol) ? true : this.ValidateHandshakeResponseHeader(
                    "sec-websocket-protocol",
                    v => v.Equals(this.Protocol, StringComparison.Ordinal),
                    new ProtocolViolationException("Server protocol violation. Server did not respond with sec-websocket-protocol header that matches the protocol sent on request.")),
                () => this.ValidateHandshakeResponseHeader(
                        "sec-websocket-extensions",
                        v => v.Equals("http2", StringComparison.OrdinalIgnoreCase),
                        new ProtocolViolationException("Server protocol violation. Server did not respond with sec-websocket-extensions header that matches the protocol sent on request.")),
                () =>
                {
                    if (this.handshakeResponseHeaders.ContainsKey("set-cookie") || this.handshakeResponseHeaders.ContainsKey("set-cookie2"))
                    {
                        this.FailWebSocketConnection(new NotSupportedException("Server attempted to set cookies with handshake response. Cookies are not supported yet."), false);
                        return false;
                    }

                    return true;
                }
            };

            if (validators.All(v => v()))
            {
                this.Connected();

                if (EnableServerPing)
                {
                    // Setup ping timer to ping the server every ServerPingInterval.
                    this.pingTimer = new Timer(this.PingTimerCallback, null, TimeSpan.Zero, ServerPingInterval);
                }

                this.ProcessMessages();
            }
        }
开发者ID:kapryeong,项目名称:HTTP-SPEED-PLUS-MOBILITY,代码行数:49,代码来源:IETFHyBiWebSocketPotocol.cs

示例2: TipoEmpresaValido

        private bool TipoEmpresaValido(ParametroSistemaEmpresa parametroSistemaEmpresa, ParametrosSistema parametroSistema)
        {
            var reglas = new Func<ParametroSistemaEmpresa, bool>[]
            {
                ps => (ps.EmpresaId == 1 || ps.EmpresaId == 2) && parametroSistema.TipoDeParametro != 1,
                ps => (ps.EmpresaId != 1 && ps.EmpresaId != 2) && parametroSistema.TipoDeParametro != 2
            };

            return reglas.All(regla => regla(parametroSistemaEmpresa) == false);
        }
开发者ID:xblizz,项目名称:ProyectoSistemasInformacion,代码行数:10,代码来源:ParametrosController.cs


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