public static bool Execute(this Func <bool> _func, FuncMode _mode = FuncMode.Any, bool _onNull = false) { if (_func == null) { return(_onNull); } bool result = false; Delegate[] list = _func.GetInvocationList(); switch (_mode) { case FuncMode.Any: result = false; for (int i = 0; i < list.Length; i++) { result |= (bool)list[i].DynamicInvoke(); } break; case FuncMode.All: result = true; for (int i = 0; i < list.Length; i++) { result &= (bool)list[i].DynamicInvoke(); } break; } return(result); }
/// <inheritdoc /> public bool Equals([AllowNull] Aggregation other) { if (other == null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Target == other.Target || Target != null && Target.Equals(other.Target) ) && ( Func == other.Func || Func != null && Func.Equals(other.Func) ) && ( FuncMode == other.FuncMode || FuncMode != null && FuncMode.Equals(other.FuncMode) ) && ( Enabled == other.Enabled || Enabled != null && Enabled.Equals(other.Enabled) )); }
public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = 41; if (Target != null) { hashCode = hashCode * 59 + Target.GetHashCode(); } if (Func != null) { hashCode = hashCode * 59 + Func.GetHashCode(); } if (FuncMode != null) { hashCode = hashCode * 59 + FuncMode.GetHashCode(); } if (Enabled != null) { hashCode = hashCode * 59 + Enabled.GetHashCode(); } return(hashCode); } }