/// <summary> /// Tries to get the <see cref="ImmutableKeyValue"/> with the specified key /// </summary> /// <param name="propertyName"></param> /// <param name="value"></param> /// <returns></returns> public bool TryGet(string propertyName, out ImmutableKeyValue value) { var record = Record; if (record.Length == 0) { throw new KeyNotFoundException(); } if (record.Type != KeyValueType.None) { throw new InvalidOperationException(); } foreach (ImmutableKeyValue keyValue in this) { if (keyValue.Utf8Key == propertyName) { value = keyValue; return(true); } } value = default; return(false); }
public KeyValueResultsView(ImmutableKeyValue value) { object[] items = new object[value.Length]; int i = 0; foreach (var subKey in value) { items[i] = subKey.Type == 0 ? (object)new ValuesTypeProxy(subKey) : new ValueTypeProxy(subKey); i++; } Items = items; }
public ValuesTypeProxy(ImmutableKeyValue kv) { _key = kv.Key; object[] items = new object[kv.Length]; int i = 0; foreach (var subKey in kv) { items[i] = subKey.Type == 0 ? (object)new ValuesTypeProxy(subKey) : new ValueTypeProxy(subKey); i++; } Items = items; }
private void AddValue(ImmutableKeyValue kv, KeyValue instance) { switch (kv.Type) { case KeyValueType.None: KeyValue subKey = instance.GetOrAdd(kv.Key); foreach (ImmutableKeyValue immutableSubKey in kv) { AddValue(immutableSubKey, subKey); } break; case KeyValueType.Float: instance.Add(kv.Key, kv.GetFloat()); break; case KeyValueType.Int32: instance.Add(kv.Key, kv.GetInt32()); break; case KeyValueType.Int64: instance.Add(kv.Key, kv.GetInt64()); break; case KeyValueType.Pointer: instance.Add(kv.Key, kv.GetIntPtr()); break; case KeyValueType.String: instance.Add(kv.Key, kv.GetString()); break; case KeyValueType.UInt64: instance.Add(kv.Key, kv.GetUInt64()); break; case KeyValueType.WideString: instance.Add(kv.Key, kv.GetString()); break; case KeyValueType.Color: instance.Add(kv.Key, kv.GetColor()); break; } }
internal Enumerator(ImmutableKeyValue keyValue) { _keyValues = keyValue; _db = keyValue._db.GetEnumerator(); }
public ValueTypeProxy(ImmutableKeyValue kv) { _key = kv.Key; _type = kv.Type; _value = kv.GetValue(true); }