public AcceptEncodingBuilder Add(AcceptEncodingType encoding, float weight = 1.0f) { if (weight < 0 || weight > 1) { throw new ArgumentException($"Invalid weight {weight}. It must be a value between 0 and 1 included."); } _encodings ??= new ConstantGrowArray <Pair>(1); _encodings.Add(new Pair(encoding, weight)); return(this); }
public static string GetMemberValue(this AcceptEncodingType type) { if (type == AcceptEncodingType.Unknown) { throw new ArgumentOutOfRangeException(nameof(type), type, null); } if (type == AcceptEncodingType.Brotli) { return("br"); } if (type == AcceptEncodingType.Any) { return("*"); } return(type.ToString().ToLowerInvariant()); }
public Pair(AcceptEncodingType type, float weight) { Type = type; Weight = weight; }