本文整理汇总了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();
}
}
示例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);
}