public override bool Equals([NotNullWhen(true)] object?obj) { WarningHeaderValue?other = obj as WarningHeaderValue; if (other == null) { return(false); } // 'agent' is a host/token, i.e. use case-insensitive comparison. Use case-sensitive comparison for 'text' // since it is a quoted string. if ((_code != other._code) || (!string.Equals(_agent, other._agent, StringComparison.OrdinalIgnoreCase)) || (!string.Equals(_text, other._text, StringComparison.Ordinal))) { return(false); } // We have a date set. Verify 'other' has also a date that matches our value. if (_date.HasValue) { return(other._date.HasValue && (_date.Value == other._date.Value)); } // We don't have a date. If 'other' has a date, we're not equal. return(!other._date.HasValue); }
public static bool TryParse([NotNullWhen(true)] string?input, [NotNullWhen(true)] out WarningHeaderValue?parsedValue) { int index = 0; parsedValue = null; if (GenericHeaderParser.SingleValueWarningParser.TryParseValue(input, null, ref index, out object?output)) { parsedValue = (WarningHeaderValue)output !; return(true); } return(false); }