-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(storage): added a SQLite persistence layer for saving clips betw…
…een runs. (#5)
- Loading branch information
Showing
7 changed files
with
175 additions
and
11 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 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,27 @@ | ||
namespace SharpFM.App.Models; | ||
|
||
/// <summary> | ||
/// Clip Data Model | ||
/// </summary> | ||
public class Clip | ||
{ | ||
/// <summary> | ||
/// Database Id | ||
/// </summary> | ||
public int ClipId { get; set; } | ||
|
||
/// <summary> | ||
/// Display name for clip may match Name inside the xml data or may not. | ||
/// </summary> | ||
public string ClipName { get; set; } = string.Empty; | ||
|
||
/// <summary> | ||
/// The data format to use when putting the data back on the clipboard for FileMaker. | ||
/// </summary> | ||
public string ClipType { get; set; } = string.Empty; | ||
|
||
/// <summary> | ||
/// Raw xml data from the clip. | ||
/// </summary> | ||
public string ClipXml { get; set; } = string.Empty; | ||
} |
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,36 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
using System; | ||
|
||
|
||
namespace SharpFM.App.Models; | ||
|
||
/// <summary> | ||
/// Clip Db Context | ||
/// </summary> | ||
public class ClipDbContext : DbContext | ||
{ | ||
/// <summary> | ||
/// Clips stored in the Db. | ||
/// </summary> | ||
public DbSet<Clip> Clips => Set<Clip>(); | ||
|
||
/// <summary> | ||
/// Database path. | ||
/// </summary> | ||
public string DbPath { get; } | ||
|
||
/// <summary> | ||
/// Constructor. | ||
/// </summary> | ||
public ClipDbContext() | ||
{ | ||
var folder = Environment.SpecialFolder.LocalApplicationData; | ||
var path = Environment.GetFolderPath(folder); | ||
DbPath = System.IO.Path.Join(path, "sharpFM.db"); | ||
} | ||
|
||
// The following configures EF to create a Sqlite database file in the | ||
// special "local" folder for your platform. | ||
protected override void OnConfiguring(DbContextOptionsBuilder options) | ||
=> options.UseSqlite($"Data Source={DbPath}"); | ||
} |
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 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