-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
angepasstes Readmodel aus Eventsourcing
- Loading branch information
1 parent
138591a
commit 2c707eb
Showing
10 changed files
with
87 additions
and
159 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
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
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 GrauhundReisen.ReadModelFunktional | ||
|
||
open EventSourcing | ||
open System.IO | ||
open Newtonsoft.Json | ||
|
||
module FileKeyValueStore = | ||
|
||
let createFileStore<'key,'value> (path : string) : IKeyValueStore<'key,'value> = | ||
let readFromFile key = | ||
try | ||
let path = Path.Combine (path, key.ToString()) | ||
if not <| File.Exists path then None else | ||
let content = File.ReadAllText path | ||
JsonConvert.DeserializeObject<'value> content | ||
|> Some | ||
with | ||
| _ -> None | ||
let writeToFile (key, value) = | ||
let path = Path.Combine(path, key.ToString()) | ||
let json = JsonConvert.SerializeObject value | ||
if File.Exists path then File.Delete path else | ||
File.WriteAllText(path, json) | ||
{ new IKeyValueStore<'key,'value> with | ||
member __.Read key = readFromFile key | ||
member __.Save key value = writeToFile (key, value) | ||
} |
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,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Newtonsoft.Json" version="6.0.5" targetFramework="net45" /> | ||
</packages> |
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