Ejemplo n.º 1
0
        public override IAsyncOperation <IReadOnlyList <IStorageItem> > GetItemsAsync(uint startIndex, uint maxItemsToRetrieve)
        {
            return(AsyncInfo.Run <IReadOnlyList <IStorageItem> >(async(cancellationToken) =>
            {
                var res = await GetFolderAndItems(Path, true, (int)startIndex, (int)maxItemsToRetrieve);
                if (res.Items is null)
                {
                    return null;
                }

                var items = new List <IStorageItem>();
                foreach (var entry in res.Items)
                {
                    if (entry.IsFolder)
                    {
                        items.Add(ShellStorageFolder.FromShellItem(entry));
                    }
                    else
                    {
                        items.Add(ShellStorageFile.FromShellItem(entry));
                    }
                }
                return items;
            }));
        }
Ejemplo n.º 2
0
        public override IAsyncOperation <IStorageItem> GetItemAsync(string name)
        {
            return(AsyncInfo.Run <IStorageItem>(async(cancellationToken) =>
            {
                var res = await GetFolderAndItems(Path, true);
                if (res.Items is null)
                {
                    return null;
                }

                var entry = res.Items.FirstOrDefault(x => x.FileName != null && x.FileName.Equals(name, StringComparison.OrdinalIgnoreCase));
                if (entry is null)
                {
                    return null;
                }

                if (entry.IsFolder)
                {
                    return ShellStorageFolder.FromShellItem(entry);
                }

                return ShellStorageFile.FromShellItem(entry);
            }));
        }