-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1817 from pchaigno/fix-fs-heuristic
Fix .fs heuristic
- Loading branch information
Showing
2 changed files
with
51 additions
and
2 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,49 @@ | ||
namespace Nessos.FsPickler.Combinators | ||
|
||
open Nessos.FsPickler | ||
open Nessos.FsPickler.Json | ||
|
||
/// Json pickling methods | ||
[<RequireQualifiedAccess>] | ||
module Json = | ||
|
||
let private jsonSerializer = lazy(FsPickler.CreateJson(omitHeader = true)) | ||
|
||
/// <summary> | ||
/// Pickles a value to Json. | ||
/// </summary> | ||
/// <param name="pickler">utilized pickler.</param> | ||
/// <param name="value">input value.</param> | ||
let pickle (pickler : Pickler<'T>) (value : 'T) : string = | ||
jsonSerializer.Value.PickleToString (pickler, value) | ||
|
||
/// <summary> | ||
/// Unpickles a value from Json. | ||
/// </summary> | ||
/// <param name="pickler">utilized pickler.</param> | ||
/// <param name="pickle">input pickle.</param> | ||
let unpickle (pickler : Pickler<'T>) (pickle : string) : 'T = | ||
jsonSerializer.Value.UnPickleOfString (pickler, pickle) | ||
|
||
|
||
/// Bson pickling methods | ||
[<RequireQualifiedAccess>] | ||
module Bson = | ||
|
||
let private bsonPickler = lazy(FsPickler.CreateBson()) | ||
|
||
/// <summary> | ||
/// Pickles a value to Bson. | ||
/// </summary> | ||
/// <param name="pickler">utilized pickler.</param> | ||
/// <param name="value">input value.</param> | ||
let pickle (pickler : Pickler<'T>) (value : 'T) : byte [] = | ||
bsonPickler.Value.Pickle (pickler, value) | ||
|
||
/// <summary> | ||
/// Unpickles a value from bson. | ||
/// </summary> | ||
/// <param name="pickler">utilized pickler.</param> | ||
/// <param name="pickle">input pickle.</param> | ||
let unpickle (pickler : Pickler<'T>) (pickle : byte []) : 'T = | ||
bsonPickler.Value.UnPickle (pickler, pickle) |