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