Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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());
        }
Exemplo n.º 3
0
 public Pair(AcceptEncodingType type, float weight)
 {
     Type   = type;
     Weight = weight;
 }