internal static IEnumerable <IfHeaderCondition> Parse([NotNull] StringSource source, [NotNull] EntityTagComparer entityTagComparer) { while (!source.SkipWhiteSpace()) { var isNot = false; EntityTag?etag = null; if (source.AdvanceIf("Not", StringComparison.OrdinalIgnoreCase)) { isNot = true; source.SkipWhiteSpace(); } Uri stateToken; if (CodedUrlParser.TryParse(source, out stateToken)) { // Coded-URL found } else if (source.Get() == '[') { // Entity-tag found etag = EntityTag.Parse(source).Single(); if (!source.AdvanceIf("]")) { throw new ArgumentException($"{source.Remaining} is not a valid condition (ETag not ending with ']')", nameof(source)); } } else { source.Back(); break; } yield return(new IfHeaderCondition(isNot, stateToken, etag, entityTagComparer)); } }
public static IfNoneMatchHeader Parse([CanBeNull] string s, [NotNull] EntityTagComparer etagComparer) { if (string.IsNullOrWhiteSpace(s) || s == "*") { return(new IfNoneMatchHeader()); } return(new IfNoneMatchHeader(EntityTag.Parse(s), etagComparer)); }
public static IfNoneMatchHeader Parse([NotNull][ItemNotNull] IEnumerable <string> s, [NotNull] EntityTagComparer etagComparer) { var result = new List <EntityTag>(); foreach (var etag in s) { if (etag == "*") { return(new IfNoneMatchHeader()); } result.AddRange(EntityTag.Parse(etag)); } if (result.Count == 0) { return(new IfNoneMatchHeader()); } return(new IfNoneMatchHeader(result, etagComparer)); }