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

                value = tmp;
                return(result);
            }
コード例 #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);
            }
コード例 #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);
            }
コード例 #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);
            }
コード例 #6
0
 public FourElementMap(JwtMember value1, JwtMember value2, JwtMember value3, JwtMember value4)
 {
     _value1 = value1;
     _value2 = value2;
     _value3 = value3;
     _value4 = value4;
 }
コード例 #7
0
 public void WriteTo(Utf8JsonWriter writer)
 {
     for (int i = 0; i < _count; i++)
     {
         JwtMember pair = _keyValues[i];
         pair.WriteTo(writer);
     }
 }
コード例 #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);
            }
コード例 #9
0
            public IMap Merge(IMap map)
            {
                for (int i = 0; i < _count; i++)
                {
                    JwtMember item = _keyValues[i];
                    map = map.Add(item);
                }

                return(map);
            }
コード例 #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);
            }
コード例 #11
0
 public IMap Add(JwtMember value)
 {
     if (value.Name.Equals(_value1.Name))
     {
         return(new OneElementMap(value));
     }
     else
     {
         return(new TwoElementMap(_value1, value));
     }
 }
コード例 #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);
            }
コード例 #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);
            }
コード例 #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);
            }
コード例 #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);
            }
コード例 #16
0
 public OneElementMap(JwtMember value)
 {
     _value1 = value;
 }
コード例 #17
0
 public void UnsafeStore(int index, JwtMember value)
 {
     Debug.Assert(index < _keyValues.Length);
     _keyValues[index] = value;
 }
コード例 #18
0
 public IMap Add(JwtMember value)
 => new OneElementMap(value);
コード例 #19
0
 public ThreeElementMap(JwtMember value1, JwtMember value2, JwtMember value3)
 {
     _value1 = value1;
     _value2 = value2;
     _value3 = value3;
 }
コード例 #20
0
 public TwoElementMap(JwtMember value1, JwtMember value2)
 {
     _value1 = value1;
     _value2 = value2;
 }
コード例 #21
0
 public IMap Add(JwtMember value)
 => new TwoElementMap(_value1, value);
コード例 #22
0
 public IMap Add(JwtMember value)
 {
     _dictionary[value.Name] = value;
     return(this);
 }
コード例 #23
0
 public bool TryGetValue(JsonEncodedText key, [NotNullWhen(true)] out JwtMember value)
 {
     // Nothing here
     value = default;
     return(false);
 }