public new T this[int index] { get { return(base[index]); } set { if (index < 0) { throw new ArgumentOutOfRangeException(nameof(value)); } var realmValue = Operator.Convert <T, RealmValue>(value); if (_isEmbedded) { Realm.ManageEmbedded(EnsureUnmanagedEmbedded(realmValue), _listHandle.SetEmbedded(index)); return; } AddToRealmIfNecessary(realmValue); _listHandle.Set(index, realmValue); } }
public TValue this[string key] { get { if (TryGetValue(key, out var result)) { return(result); } throw new KeyNotFoundException($"The given key '{key}' was not present in the dictionary."); } set { EnsureKeyNotNull(key); var realmValue = Operator.Convert <TValue, RealmValue>(value); if (_isEmbedded && realmValue.Type != RealmValueType.Null) { Realm.ManageEmbedded(EnsureUnmanagedEmbedded(realmValue), _dictionaryHandle.SetEmbedded(key)); return; } AddToRealmIfNecessary(realmValue); _dictionaryHandle.Set(key, realmValue); } }
public void Add(T value) { var realmValue = Operator.Convert <T, RealmValue>(value); if (_isEmbedded) { Realm.ManageEmbedded(EnsureUnmanagedEmbedded(realmValue), _listHandle.AddEmbedded()); return; } AddToRealmIfNecessary(realmValue); _listHandle.Add(realmValue); }
public void Add(string key, TValue value) { EnsureKeyNotNull(key); var realmValue = Operator.Convert <TValue, RealmValue>(value); if (_isEmbedded && realmValue.Type != RealmValueType.Null) { Realm.ManageEmbedded(EnsureUnmanagedEmbedded(realmValue), _dictionaryHandle.AddEmbedded(key)); return; } AddToRealmIfNecessary(realmValue); _dictionaryHandle.Add(key, realmValue); }
public void Insert(int index, T value) { if (index < 0) { throw new ArgumentOutOfRangeException(nameof(index)); } var realmValue = Operator.Convert <T, RealmValue>(value); if (_isEmbedded) { Realm.ManageEmbedded(EnsureUnmanagedEmbedded(realmValue), _listHandle.InsertEmbedded(index)); return; } AddToRealmIfNecessary(realmValue); _listHandle.Insert(index, realmValue); }