// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.ComponentModel; using JetBrains.Annotations; using Realms; using Realms.Schema; namespace osu.Game.Database { /// /// This can arrive in callbacks to imply that realm access has been reset. /// /// /// Usually implies that the original database may return soon and the callback can usually be silently ignored. /// public class RealmResetEmptySet : IRealmCollection { private IList emptySet => Array.Empty(); [MustDisposeResource] public IEnumerator GetEnumerator() => emptySet.GetEnumerator(); [MustDisposeResource] IEnumerator IEnumerable.GetEnumerator() => emptySet.GetEnumerator(); public int Count => emptySet.Count; public T this[int index] => emptySet[index]; public int IndexOf(object? item) => item == null ? -1 : emptySet.IndexOf((T)item); public bool Contains(object? item) => item != null && emptySet.Contains((T)item); public event NotifyCollectionChangedEventHandler? CollectionChanged { add => throw new NotImplementedException(); remove => throw new NotImplementedException(); } public event PropertyChangedEventHandler? PropertyChanged { add => throw new NotImplementedException(); remove => throw new NotImplementedException(); } public IRealmCollection Freeze() => throw new NotImplementedException(); public IDisposable SubscribeForNotifications(NotificationCallbackDelegate callback) => throw new NotImplementedException(); public bool IsValid => throw new NotImplementedException(); public Realm Realm => throw new NotImplementedException(); public ObjectSchema ObjectSchema => throw new NotImplementedException(); public bool IsFrozen => throw new NotImplementedException(); } }