Exemple #1
0
        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);
            }
        }
Exemple #2
0
        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);
            }
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        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);
        }
Exemple #5
0
        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);
        }