Exemplo n.º 1
0
 /// <inheritdoc/>
 public override bool TryGetElement(int index, out VariantValue value)
 {
     if (index >= 0 && _value is IList <object> o && index < o.Count)
     {
         value = new MessagePackVariantValue(o[index], _options, false,
                                             v => o[index] = v);
         return(true);
     }
     value = null;
     return(false);
 }
Exemplo n.º 2
0
 /// <inheritdoc/>
 public override bool TryGetProperty(string key, out VariantValue value,
                                     StringComparison compare)
 {
     if (_value is IDictionary <object, object> o)
     {
         var success = o.FirstOrDefault(kv => key.Equals((string)kv.Key, compare));
         if (success.Value != null)
         {
             value = new MessagePackVariantValue(success.Value, _options, false,
                                                 v => o.AddOrUpdate(success.Key, v));
             return(true);
         }
     }
     value = null;
     return(false);
 }