2020-03-24 13:01:14 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2020-04-09 19:43:06 +02:00
|
|
|
|
using System.Linq;
|
2020-03-24 13:01:14 +01:00
|
|
|
|
using Windows.Storage.AccessCache;
|
|
|
|
|
using ModernKeePass.Application.Common.Interfaces;
|
|
|
|
|
using ModernKeePass.Domain.Dtos;
|
|
|
|
|
|
|
|
|
|
namespace ModernKeePass.Infrastructure.UWP
|
|
|
|
|
{
|
|
|
|
|
public class UwpRecentFilesClient: IRecentProxy
|
|
|
|
|
{
|
|
|
|
|
private readonly StorageItemMostRecentlyUsedList _mru = StorageApplicationPermissions.MostRecentlyUsedList;
|
|
|
|
|
|
|
|
|
|
public int EntryCount => _mru.Entries.Count;
|
2020-04-24 16:16:48 +02:00
|
|
|
|
|
2020-04-09 19:43:06 +02:00
|
|
|
|
public IEnumerable<FileInfo> GetAll()
|
2020-03-24 13:01:14 +01:00
|
|
|
|
{
|
2020-04-09 19:43:06 +02:00
|
|
|
|
return _mru.Entries.Select(e => new FileInfo
|
2020-03-24 13:01:14 +01:00
|
|
|
|
{
|
2020-04-09 19:43:06 +02:00
|
|
|
|
Id = e.Token,
|
|
|
|
|
Name = e.Metadata?.Substring(e.Metadata.LastIndexOf("\\", StringComparison.OrdinalIgnoreCase) + 1),
|
|
|
|
|
Path = e.Metadata
|
|
|
|
|
});
|
2020-03-24 13:01:14 +01:00
|
|
|
|
}
|
2020-04-24 13:58:30 +02:00
|
|
|
|
|
2020-03-24 13:01:14 +01:00
|
|
|
|
public void ClearAll()
|
|
|
|
|
{
|
2020-04-09 19:43:06 +02:00
|
|
|
|
foreach (var entry in _mru.Entries)
|
2020-03-24 13:01:14 +01:00
|
|
|
|
{
|
|
|
|
|
_mru.Remove(entry.Token);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|