Revert "Add Test cases for app shortcut, managedapps"
[profile/tv/apps/dotnet/home.git] / LibTVRefCommonPortable / Utils / AppShortcutStorage.cs
index 47baace..47b9650 100644 (file)
@@ -17,7 +17,10 @@ using System;
 using System.Collections.Generic;
 using System.Xml.Serialization;
 using System.IO;
+
 using LibTVRefCommonPortable.DataModels;
+
+using Xamarin.Forms;
 using System.Threading.Tasks;
 using System.Diagnostics;
 
@@ -36,7 +39,7 @@ namespace LibTVRefCommonPortable.Utils
         /// <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.
@@ -56,7 +59,7 @@ namespace LibTVRefCommonPortable.Utils
         /// </summary>
         private AppShortcutStorage()
         {
-            StoragePath = FileSystemUtils.Instance.PlatformShareStorage + "pinned_apps_info.xml";
+            StoragePath = DependencyService.Get<IFileSystemAPIs>()?.PlatformShareStorage + "pinned_apps_info.xml";
 
             fileSystemWatcher.Run();
         }
@@ -67,7 +70,9 @@ namespace LibTVRefCommonPortable.Utils
         /// <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>();
@@ -77,7 +82,7 @@ namespace LibTVRefCommonPortable.Utils
 
             for (int i = 0; i < 5; i++)
             {
-                if (FileSystemUtils.Instance.IsFileReady(StoragePath))
+                if (fileSystem.IsFileReady(StoragePath))
                 {
                     break;
                 }
@@ -91,7 +96,7 @@ namespace LibTVRefCommonPortable.Utils
                 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);
 
@@ -110,7 +115,9 @@ namespace LibTVRefCommonPortable.Utils
         /// <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);