Ejemplo n.º 1
0
            public bool TryGetValue(JsonEncodedText key, out JwtMember value)
            {
                if (key.Equals(_value1.Name))
                {
                    value = _value1;
                }
                else if (key.Equals(_value2.Name))
                {
                    value = _value2;
                }
                else if (key.Equals(_value3.Name))
                {
                    value = _value3;
                }
                else
                {
#if NET5_0_OR_GREATER
                    Unsafe.SkipInit(out value);
#else
                    value = default;
#endif
                    return(false);
                }

                return(true);
            }
Ejemplo n.º 2
0
            public bool TryGetValue(JsonEncodedText key, out JwtMember value)
            {
                var result = _dictionary.TryGetValue(key, out var tmp);

                value = tmp;
                return(result);
            }
Ejemplo n.º 3
0
            public IMap Add(JwtMember value)
            {
                if (_count < MaxMultiElements)
                {
                    for (int i = 0; i < _count; i++)
                    {
                        if (value.Name.Equals(_keyValues[i].Name))
                        {
                            _keyValues[i] = value;
                            goto Added;
                        }
                    }

                    UnsafeStore(_count, value);
                    _count++;
Added:
                    return(this);
                }

                // Otherwise, upgrade to a many map.
                var many = new ManyElementMap(MaxMultiElements + 1);

                for (int i = 0; i < _count; i++)
                {
                    JwtMember pair = _keyValues[i];
                    many[pair.Name] = pair;
                }

                many[value.Name] = value;
                return(many);
            }
Ejemplo n.º 4
0
            public bool TryGetValue(JsonEncodedText key, out JwtMember value)
            {
                if (key.Equals(_value1.Name))
                {
                    value = _value1;
                }
                else if (key.Equals(_value2.Name))
                {
                    value = _value2;
                }
                else if (key.Equals(_value3.Name))
                {
                    value = _value3;
                }
                else if (key.Equals(_value4.Name))
                {
                    value = _value4;
                }
                else
                {
                    value = default;
                    return(false);
                }

                return(true);
            }
Ejemplo n.º 5
0
            public IMap Add(JwtMember value)
            {
                IMap map;

                if (value.Name.Equals(_value1.Name))
                {
                    map = new FourElementMap(value, _value2, _value3, _value4);
                }
                else if (value.Name.Equals(_value2.Name))
                {
                    map = new FourElementMap(_value1, value, _value3, _value4);
                }
                else if (value.Name.Equals(_value3.Name))
                {
                    map = new FourElementMap(_value1, _value2, value, _value4);
                }
                else if (value.Name.Equals(_value4.Name))
                {
                    map = new FourElementMap(_value1, _value2, _value3, value);
                }
                else
                {
                    var multi = new MultiElementMap(5);
                    multi.UnsafeStore(0, _value1);
                    multi.UnsafeStore(1, _value2);
                    multi.UnsafeStore(2, _value3);
                    multi.UnsafeStore(3, _value4);
                    multi.UnsafeStore(4, value);
                    map = multi;
                }

                return(map);
            }
Ejemplo n.º 6
0
 public FourElementMap(JwtMember value1, JwtMember value2, JwtMember value3, JwtMember value4)
 {
     _value1 = value1;
     _value2 = value2;
     _value3 = value3;
     _value4 = value4;
 }
Ejemplo n.º 7
0
 public void WriteTo(Utf8JsonWriter writer)
 {
     for (int i = 0; i < _count; i++)
     {
         JwtMember pair = _keyValues[i];
         pair.WriteTo(writer);
     }
 }
Ejemplo n.º 8
0
            public IMap Add(JwtMember value)
            {
                // Create a new one-element map to store the key/value pair
                //map = new OneElementMap(value);
                var map = new MultiElementMap(1);

                map.UnsafeStore(0, value);
                return(map);
            }
Ejemplo n.º 9
0
            public IMap Merge(IMap map)
            {
                for (int i = 0; i < _count; i++)
                {
                    JwtMember item = _keyValues[i];
                    map = map.Add(item);
                }

                return(map);
            }
Ejemplo n.º 10
0
            public bool TryGetValue(JsonEncodedText key, [NotNullWhen(true)] out JwtMember value)
            {
                // Nothing here
#if NET5_0_OR_GREATER
                Unsafe.SkipInit(out value);
#else
                value = default;
#endif
                return(false);
            }
Ejemplo n.º 11
0
 public IMap Add(JwtMember value)
 {
     if (value.Name.Equals(_value1.Name))
     {
         return(new OneElementMap(value));
     }
     else
     {
         return(new TwoElementMap(_value1, value));
     }
 }
Ejemplo n.º 12
0
            public bool ContainsKey(JsonEncodedText key)
            {
                for (int i = 0; i < _count; i++)
                {
                    JwtMember pair = _keyValues[i];
                    if (key.Equals(pair.Name))
                    {
                        return(true);
                    }
                }

                return(false);
            }
Ejemplo n.º 13
0
            public bool TryGetValue(JsonEncodedText key, out JwtMember value)
            {
                for (int i = 0; i < _count; i++)
                {
                    JwtMember pair = _keyValues[i];
                    if (key.Equals(pair.Name))
                    {
                        value = pair;
                        return(true);
                    }
                }

                value = default;
                return(false);
            }
Ejemplo n.º 14
0
            public IMap Add(JwtMember value)
            {
                IMap map;

                if (value.Name.Equals(_value1.Name))
                {
                    map = new TwoElementMap(value, _value2);
                }
                else if (value.Name.Equals(_value2.Name))
                {
                    map = new TwoElementMap(_value1, value);
                }
                else
                {
                    map = new ThreeElementMap(_value1, _value2, value);
                }

                return(map);
            }
Ejemplo n.º 15
0
            public bool TryGetValue(JsonEncodedText key, out JwtMember value)
            {
                for (int i = 0; i < _count; i++)
                {
                    JwtMember pair = _keyValues[i];
                    if (key.Equals(pair.Name))
                    {
                        value = pair;
                        return(true);
                    }
                }

#if NET5_0_OR_GREATER
                Unsafe.SkipInit(out value);
#else
                value = default;
#endif
                return(false);
            }
Ejemplo n.º 16
0
 public OneElementMap(JwtMember value)
 {
     _value1 = value;
 }
Ejemplo n.º 17
0
 public void UnsafeStore(int index, JwtMember value)
 {
     Debug.Assert(index < _keyValues.Length);
     _keyValues[index] = value;
 }
Ejemplo n.º 18
0
 public IMap Add(JwtMember value)
 => new OneElementMap(value);
Ejemplo n.º 19
0
 public ThreeElementMap(JwtMember value1, JwtMember value2, JwtMember value3)
 {
     _value1 = value1;
     _value2 = value2;
     _value3 = value3;
 }
Ejemplo n.º 20
0
 public TwoElementMap(JwtMember value1, JwtMember value2)
 {
     _value1 = value1;
     _value2 = value2;
 }
Ejemplo n.º 21
0
 public IMap Add(JwtMember value)
 => new TwoElementMap(_value1, value);
Ejemplo n.º 22
0
 public IMap Add(JwtMember value)
 {
     _dictionary[value.Name] = value;
     return(this);
 }
Ejemplo n.º 23
0
 public bool TryGetValue(JsonEncodedText key, [NotNullWhen(true)] out JwtMember value)
 {
     // Nothing here
     value = default;
     return(false);
 }