Skip to content

Commit

Permalink
Remove Newtonsoft.Json.Linq deps
Browse files Browse the repository at this point in the history
  • Loading branch information
bartelink committed Sep 5, 2017
1 parent f684211 commit eb2c29a
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions src/Foldunk/EventSum.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

open Foldunk.Serialization
open Newtonsoft.Json
open Newtonsoft.Json.Linq
open System
open System.Runtime.Serialization
open TypeShape
Expand Down Expand Up @@ -36,18 +35,6 @@ type Utf8JsonEncoder() =
member __.Encode (value : 'T) = JsonConvert.SerializeObject(value, settings) |> System.Text.Encoding.UTF8.GetBytes
member __.Decode (json : byte[]) = let x = System.Text.Encoding.UTF8.GetString(json) in JsonConvert.DeserializeObject<'T>(x, settings)

/// Newtonsoft.Json JObject implementation of IEncoder
type JObjectEncoder
( /// Convert .NET PascalCase properties etc. to camelCase; defaults to true
?camelCase : bool) =

let settings = Newtonsoft.GetDefaultSettings(useHyphenatedGuids = false, ?camelCase = camelCase)
let serializer = JsonSerializer.Create settings
interface IEncoder<JObject> with
member __.Empty = JObject.FromObject null
member __.Encode (value : 'T) = JObject.FromObject(value, serializer)
member __.Decode (jobj : JObject) = jobj.ToObject<'T>(serializer)

// Represents an encoded event
type EncodedEvent<'Encoding> =
{
Expand Down Expand Up @@ -154,8 +141,4 @@ let generateJsonSumEncoder<'Union> =

/// Generates an event sum encoder using Newtonsoft.Json for individual event types that serializes to a byte buffer
let generateJsonUtf8SumEncoder<'Union> =
generateSumEventEncoder<'Union, _> (new Utf8JsonEncoder())

/// Generates an event sum encoder which uses Newtonsoft.Json.Linq to wrap/unwrap the payload as a JObject
let generateJObjectSumEncoder<'Union> (encoder: IEncoder<JObject>) =
generateSumEventEncoder<'Union, JObject> encoder
generateSumEventEncoder<'Union, _> (new Utf8JsonEncoder())

0 comments on commit eb2c29a

Please sign in to comment.