Esempio 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);
            }
Esempio n. 2
0
            public bool TryGetValue(JsonEncodedText key, out JwtMember value)
            {
                var result = _dictionary.TryGetValue(key, out var tmp);

                value = tmp;
                return(result);
            }
Esempio 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);
            }
Esempio 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);
            }
Esempio 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);
            }
Esempio n. 6
0
 public FourElementMap(JwtMember value1, JwtMember value2, JwtMember value3, JwtMember value4)
 {
     _value1 = value1;
     _value2 = value2;
     _value3 = value3;
     _value4 = value4;
 }
Esempio n. 7
0
 public void WriteTo(Utf8JsonWriter writer)
 {
     for (int i = 0; i < _count; i++)
     {
         JwtMember pair = _keyValues[i];
         pair.WriteTo(writer);
     }
 }
Esempio 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);
            }
Esempio 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);
            }
Esempio 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);
            }
Esempio n. 11
0
 public IMap Add(JwtMember value)
 {
     if (value.Name.Equals(_value1.Name))
     {
         return(new OneElementMap(value));
     }
     else
     {
         return(new TwoElementMap(_value1, value));
     }
 }
Esempio 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);
            }
Esempio 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);
            }
Esempio 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);
            }
Esempio 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);
            }
Esempio n. 16
0
 public OneElementMap(JwtMember value)
 {
     _value1 = value;
 }
Esempio n. 17
0
 public void UnsafeStore(int index, JwtMember value)
 {
     Debug.Assert(index < _keyValues.Length);
     _keyValues[index] = value;
 }
Esempio n. 18
0
 public IMap Add(JwtMember value)
 => new OneElementMap(value);
Esempio n. 19
0
 public ThreeElementMap(JwtMember value1, JwtMember value2, JwtMember value3)
 {
     _value1 = value1;
     _value2 = value2;
     _value3 = value3;
 }
Esempio n. 20
0
 public TwoElementMap(JwtMember value1, JwtMember value2)
 {
     _value1 = value1;
     _value2 = value2;
 }
Esempio n. 21
0
 public IMap Add(JwtMember value)
 => new TwoElementMap(_value1, value);
Esempio n. 22
0
 public IMap Add(JwtMember value)
 {
     _dictionary[value.Name] = value;
     return(this);
 }
Esempio n. 23
0
 public bool TryGetValue(JsonEncodedText key, [NotNullWhen(true)] out JwtMember value)
 {
     // Nothing here
     value = default;
     return(false);
 }