-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
74 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System.Runtime.InteropServices.JavaScript; | ||
using System.Threading.Tasks; | ||
using NoteSHR.Core.Services; | ||
|
||
namespace NoteSHR.Browser; | ||
|
||
public class BrowserFileService : IFileService | ||
{ | ||
public BrowserFileService() | ||
{ | ||
Task.Run(async () => await JSHost.ImportAsync("FileUtils", "./fileUtils.js")); | ||
} | ||
|
||
public async Task<string?> GetFileUrl() | ||
{ | ||
var url = await FileUtilsEmbed.OpenFilePicker(); | ||
|
||
return url; | ||
} | ||
|
||
public async Task SaveFile(string fileName, string content) | ||
{ | ||
await FileUtilsEmbed.SaveFile(fileName, content); | ||
} | ||
} | ||
|
||
internal partial class FileUtilsEmbed | ||
{ | ||
[JSImport("openFilePicker", "FileUtils")] | ||
public static partial Task<string?> OpenFilePicker(); | ||
|
||
[JSImport("saveFile", "FileUtils")] | ||
public static partial Task SaveFile(string fileName, string contents); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace NoteSHR.Core.Services; | ||
|
||
public interface IFileService | ||
{ | ||
Task<string?> GetFileUrl(); | ||
Task SaveFile(string fileName, string content); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters