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)); } }
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)); } }
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)); } }