Created
May 20, 2014 05:27
-
-
Save johnazariah/21ce1cea7464d0831826 to your computer and use it in GitHub Desktop.
Serialization with FsPickler
This file contains hidden or 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
type AccountIdentifier = | |
| AccountIdentifier of System.Guid | |
type Account = { | |
Identifier : AccountIdentifier | |
Name : string | |
} | |
open Nessos.FsPickler // https://www.nuget.org/packages/FsPickler/ | |
[<EntryPoint>] | |
let main argv = | |
let id = System.Guid.NewGuid() |> AccountIdentifier | |
let account = {Identifier = id; Name = "Accounts Receiveable"} | |
let d = [ id, account ] |> Map.ofList | |
let fsp = new FsPickler() | |
let stream = new System.IO.MemoryStream() | |
fsp.Serialize<Map<AccountIdentifier, Account>>(stream, d) | |
stream.Seek(0L, System.IO.SeekOrigin.Begin) |> ignore | |
let roundTripResult = fsp.Deserialize<Map<AccountIdentifier, Account>>(stream) | |
printfn "%s" roundTripResult.[id].Name | |
0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment