using System.Collections.Generic;
using System.Xml.Serialization;
using System.IO;
+
using LibTVRefCommonPortable.DataModels;
+
+using Xamarin.Forms;
using System.Threading.Tasks;
using System.Diagnostics;
/// <summary>
/// A file system watcher which checks if the targeted storage is changed.
/// </summary>
- private static IFileSystemWatcherAPIs fileSystemWatcher = FileSystemUtils.Instance.FileSysteamWatcherInstance;
+ private static IFileSystemWatcherAPIs fileSystemWatcher = DependencyService.Get<IFileSystemWatcherAPIs>();
/// <summary>
/// An instance of AppShortcutStorage.
/// </summary>
private AppShortcutStorage()
{
- StoragePath = FileSystemUtils.Instance.PlatformShareStorage + "pinned_apps_info.xml";
+ StoragePath = DependencyService.Get<IFileSystemAPIs>()?.PlatformShareStorage + "pinned_apps_info.xml";
fileSystemWatcher.Run();
}
/// <returns>An app Shortcut list.</returns>
public static async Task<IEnumerable<AppShortcutInfo>> Read()
{
- if (FileSystemUtils.Instance.IsFileExist(StoragePath) == false)
+ IFileSystemAPIs fileSystem = DependencyService.Get<IFileSystemAPIs>();
+
+ if (fileSystem.IsFileExist(StoragePath) == false)
{
DebuggingUtils.Err("Set Default Pinned Apps" + StoragePath);
List<AppShortcutInfo> result = new List<AppShortcutInfo>();
for (int i = 0; i < 5; i++)
{
- if (FileSystemUtils.Instance.IsFileReady(StoragePath))
+ if (fileSystem.IsFileReady(StoragePath))
{
break;
}
DebuggingUtils.Dbg("[" + i + "/5] Waiting for Writing" + StoragePath);
}
- using (Stream fileStream = FileSystemUtils.Instance.OpenFile(StoragePath, UtilFileMode.Open))
+ using (Stream fileStream = fileSystem.OpenFile(StoragePath, UtilFileMode.Open))
{
Debug.Assert(fileStream != null);
/// <returns>A status of storage update.</returns>
public static bool Write(IEnumerable<AppShortcutInfo> pinnedAppInfo)
{
- using (Stream fileStream = FileSystemUtils.Instance.OpenFile(StoragePath, UtilFileMode.Create))
+ IFileSystemAPIs fileSystem = DependencyService.Get<IFileSystemAPIs>();
+
+ using (Stream fileStream = fileSystem.OpenFile(StoragePath, UtilFileMode.Create))
{
Debug.Assert(fileStream != null);