コード例 #1
0
        // Graphs

        public async Task <List <JsonGraphRootObject> > GetLocalStorageGraphs()
        {
            var localStorageGraphs = new List <JsonGraphRootObject>();

            for (var i = 0; i < await _localStorage.LengthAsync(); i++)
            {
                var key = await _localStorage.KeyAsync(i);

                JsonGraphRootObject jsonObject = null;

                try
                {
                    jsonObject = await _localStorage.GetItemAsync <JsonGraphRootObject>(key);

                    if (!(jsonObject.Vertices?.Count > 0))
                    {
                        continue;
                    }
                }
                catch (Exception)
                {
                    Console.WriteLine($"Could not convert local storage object with key '{ key }' to graph object, ignoring object.");
                }

                if (jsonObject != null)
                {
                    localStorageGraphs.Add(jsonObject);
                }
            }

            return(localStorageGraphs);
        }
        public async IAsyncEnumerable <string> GetKeysAsync([EnumeratorCancellation] CancellationToken cancellationToken)
        {
            for (int i = 0; i < await LocalStorage.LengthAsync(cancellationToken); i++)
            {
                string key = await LocalStorage.KeyAsync(i, cancellationToken);

                yield return(key);
            }
        }
コード例 #3
0
        public async Task <List <Track> > FindAllAsync()
        {
            var result = new List <Track>();
            var length = await StorageLengthAsync();

            for (var i = 0; i < length; i++)
            {
                var key = await _db.KeyAsync(i);

                if (key == CURRENT_TRACK_KEY)
                {
                    continue;
                }
                var item = await _db.GetItemAsync <Track>(key);

                if (item is not null)
                {
                    result.Add(item);
                }
            }
            return(result);
        }
コード例 #4
0
        public async ValueTask <ICollection <string> > GetAllMComponentKeys()
        {
            int length = await mLocalStorage.LengthAsync();

            var keys = new List <string>();

            for (int i = 0; i < length; i++)
            {
                var key = await mLocalStorage.KeyAsync(i);

                if (!key.StartsWith(LOCAL_STORAGE_PREFIX))
                {
                    continue;
                }

                keys.Add(key);
            }

            return(keys);
        }