Пример #1
0
 public override async Task <TResult> ReadFromLocal <TResult>(string filePath)
 {
     try
     {
         using (var stream = context.OpenFileInput(filePath))
         {
             return(await DataAccessUtil.ReadFromStream <TResult>(stream));
         }
     }
     catch (Java.IO.FileNotFoundException)
     {
         return(default(TResult));
     }
 }
Пример #2
0
        public override async Task <TResult> ReadFromApplicationPackage <TResult>(string filePath)
        {
            if (filePath.StartsWith("Assets"))
            {
                filePath = filePath.Replace("Assets/", "");
            }

            try
            {
                using (var stream = context.Assets.Open(filePath))
                {
                    return(await DataAccessUtil.ReadFromStream <TResult>(stream));
                }
            }
            catch (Java.IO.FileNotFoundException)
            {
                return(default(TResult));
            }
        }
Пример #3
0
        private async Task <TResult> Read <TResult>(string filePath, StorageFolder root)
        {
            try
            {
                var           folderPathAndFileName = ExtractFolderPathAndFileName(filePath);
                StorageFolder folder = await GetFolderAsync(folderPathAndFileName.FolderPath, root);

                if (folder == null)
                {
                    return(default(TResult));
                }

                StorageFile file = await folder.GetFileAsync(folderPathAndFileName.FileName);

                using (Stream stream = await file.OpenStreamForReadAsync())
                {
                    return(await DataAccessUtil.ReadFromStream <TResult>(stream));
                }
            }
            catch (FileNotFoundException)
            {
                return(default(TResult));
            }
        }