//------------------------------------------------------------------------------ // This code was generated by myriad. // Changes to this file will be lost when the code is regenerated. //------------------------------------------------------------------------------ namespace ConsumePlugin open System open System.Collections.Generic open System.Text.Json.Serialization /// Module containing JSON serializing extension members for the InnerTypeWithBoth type [] module InnerTypeWithBothJsonSerializeExtension = /// Extension methods for JSON parsing type InnerTypeWithBoth with /// Serialize to a JSON node static member toJsonNode (input : InnerTypeWithBoth) : System.Text.Json.Nodes.JsonNode = let node = System.Text.Json.Nodes.JsonObject () do node.Add (("it's-a-me"), System.Text.Json.Nodes.JsonValue.Create input.Thing) node.Add ( "map", (fun field -> let ret = System.Text.Json.Nodes.JsonObject () for (KeyValue (key, value)) in field do ret.Add (key.ToString (), System.Text.Json.Nodes.JsonValue.Create value) ret ) input.Map ) node.Add ( "readOnlyDict", (fun field -> let ret = System.Text.Json.Nodes.JsonObject () for (KeyValue (key, value)) in field do ret.Add ( key.ToString (), (fun field -> let arr = System.Text.Json.Nodes.JsonArray () for mem in field do arr.Add (System.Text.Json.Nodes.JsonValue.Create mem) arr ) value ) ret ) input.ReadOnlyDict ) node.Add ( "dict", (fun field -> let ret = System.Text.Json.Nodes.JsonObject () for (KeyValue (key, value)) in field do ret.Add (key.ToString (), System.Text.Json.Nodes.JsonValue.Create value) ret ) input.Dict ) node.Add ( "concreteDict", (fun field -> let ret = System.Text.Json.Nodes.JsonObject () for (KeyValue (key, value)) in field do ret.Add (key.ToString (), InnerTypeWithBoth.toJsonNode value) ret ) input.ConcreteDict ) node :> _ namespace ConsumePlugin open System open System.Collections.Generic open System.Text.Json.Serialization /// Module containing JSON serializing extension members for the JsonRecordTypeWithBoth type [] module JsonRecordTypeWithBothJsonSerializeExtension = /// Extension methods for JSON parsing type JsonRecordTypeWithBoth with /// Serialize to a JSON node static member toJsonNode (input : JsonRecordTypeWithBoth) : System.Text.Json.Nodes.JsonNode = let node = System.Text.Json.Nodes.JsonObject () do node.Add ("a", System.Text.Json.Nodes.JsonValue.Create input.A) node.Add ("b", System.Text.Json.Nodes.JsonValue.Create input.B) node.Add ( "c", (fun field -> let arr = System.Text.Json.Nodes.JsonArray () for mem in field do arr.Add (System.Text.Json.Nodes.JsonValue.Create mem) arr ) input.C ) node.Add ("d", InnerTypeWithBoth.toJsonNode input.D) node.Add ( "e", (fun field -> let arr = System.Text.Json.Nodes.JsonArray () for mem in field do arr.Add (System.Text.Json.Nodes.JsonValue.Create mem) arr ) input.E ) node.Add ( "arr", (fun field -> let arr = System.Text.Json.Nodes.JsonArray () for mem in field do arr.Add (System.Text.Json.Nodes.JsonValue.Create mem) arr ) input.Arr ) node.Add ("byte", System.Text.Json.Nodes.JsonValue.Create> input.Byte) node.Add ("sbyte", System.Text.Json.Nodes.JsonValue.Create> input.Sbyte) node.Add ("i", System.Text.Json.Nodes.JsonValue.Create> input.I) node.Add ("i32", System.Text.Json.Nodes.JsonValue.Create> input.I32) node.Add ("i64", System.Text.Json.Nodes.JsonValue.Create> input.I64) node.Add ("u", System.Text.Json.Nodes.JsonValue.Create> input.U) node.Add ("u32", System.Text.Json.Nodes.JsonValue.Create> input.U32) node.Add ("u64", System.Text.Json.Nodes.JsonValue.Create> input.U64) node.Add ("f", System.Text.Json.Nodes.JsonValue.Create> input.F) node.Add ("f32", System.Text.Json.Nodes.JsonValue.Create> input.F32) node.Add ("single", System.Text.Json.Nodes.JsonValue.Create> input.Single) node :> _ namespace ConsumePlugin open System open System.Collections.Generic open System.Text.Json.Serialization /// Module containing JSON serializing extension members for the FirstDu type [] module FirstDuJsonSerializeExtension = /// Extension methods for JSON parsing type FirstDu with /// Serialize to a JSON node static member toJsonNode (input : FirstDu) : System.Text.Json.Nodes.JsonNode = let node = System.Text.Json.Nodes.JsonObject () match input with | FirstDu.EmptyCase -> node.Add ("type", System.Text.Json.Nodes.JsonValue.Create "emptyCase") | FirstDu.Case1 arg0 -> node.Add ("type", System.Text.Json.Nodes.JsonValue.Create "case1") let dataNode = System.Text.Json.Nodes.JsonObject () dataNode.Add ("data", System.Text.Json.Nodes.JsonValue.Create arg0) node.Add ("data", dataNode) | FirstDu.Case2 (arg0, arg1) -> node.Add ("type", System.Text.Json.Nodes.JsonValue.Create "case2") let dataNode = System.Text.Json.Nodes.JsonObject () dataNode.Add ("record", JsonRecordTypeWithBoth.toJsonNode arg0) dataNode.Add ("i", System.Text.Json.Nodes.JsonValue.Create arg1) node.Add ("data", dataNode) node :> _ namespace ConsumePlugin /// Module containing JSON parsing extension members for the InnerTypeWithBoth type [] module InnerTypeWithBothJsonParseExtension = /// Extension methods for JSON parsing type InnerTypeWithBoth with /// Parse from a JSON node. static member jsonParse (node : System.Text.Json.Nodes.JsonNode) : InnerTypeWithBoth = let arg_4 = (match node.["concreteDict"] with | null -> raise ( System.Collections.Generic.KeyNotFoundException ( sprintf "Required key '%s' not found on JSON object" ("concreteDict") ) ) | v -> v) .AsObject () |> Seq.map (fun kvp -> let key = (kvp.Key) let value = InnerTypeWithBoth.jsonParse (kvp.Value) key, value ) |> Seq.map System.Collections.Generic.KeyValuePair |> System.Collections.Generic.Dictionary let arg_3 = (match node.["dict"] with | null -> raise ( System.Collections.Generic.KeyNotFoundException ( sprintf "Required key '%s' not found on JSON object" ("dict") ) ) | v -> v) .AsObject () |> Seq.map (fun kvp -> let key = (kvp.Key) |> System.Uri let value = (kvp.Value).AsValue().GetValue () key, value ) |> dict let arg_2 = (match node.["readOnlyDict"] with | null -> raise ( System.Collections.Generic.KeyNotFoundException ( sprintf "Required key '%s' not found on JSON object" ("readOnlyDict") ) ) | v -> v) .AsObject () |> Seq.map (fun kvp -> let key = (kvp.Key) let value = (kvp.Value).AsArray () |> Seq.map (fun elt -> elt.AsValue().GetValue ()) |> List.ofSeq key, value ) |> readOnlyDict let arg_1 = (match node.["map"] with | null -> raise ( System.Collections.Generic.KeyNotFoundException ( sprintf "Required key '%s' not found on JSON object" ("map") ) ) | v -> v) .AsObject () |> Seq.map (fun kvp -> let key = (kvp.Key) let value = (kvp.Value).AsValue().GetValue () |> System.Uri key, value ) |> Map.ofSeq let arg_0 = (match node.[("it's-a-me")] with | null -> raise ( System.Collections.Generic.KeyNotFoundException ( sprintf "Required key '%s' not found on JSON object" (("it's-a-me")) ) ) | v -> v) .AsValue() .GetValue () |> System.Guid.Parse { Thing = arg_0 Map = arg_1 ReadOnlyDict = arg_2 Dict = arg_3 ConcreteDict = arg_4 } namespace ConsumePlugin /// Module containing JSON parsing extension members for the JsonRecordTypeWithBoth type [] module JsonRecordTypeWithBothJsonParseExtension = /// Extension methods for JSON parsing type JsonRecordTypeWithBoth with /// Parse from a JSON node. static member jsonParse (node : System.Text.Json.Nodes.JsonNode) : JsonRecordTypeWithBoth = let arg_16 = (match node.["single"] with | null -> raise ( System.Collections.Generic.KeyNotFoundException ( sprintf "Required key '%s' not found on JSON object" ("single") ) ) | v -> v) .AsValue() .GetValue () |> LanguagePrimitives.Float32WithMeasure let arg_15 = (match node.["f32"] with | null -> raise ( System.Collections.Generic.KeyNotFoundException ( sprintf "Required key '%s' not found on JSON object" ("f32") ) ) | v -> v) .AsValue() .GetValue () |> LanguagePrimitives.Float32WithMeasure let arg_14 = (match node.["f"] with | null -> raise ( System.Collections.Generic.KeyNotFoundException ( sprintf "Required key '%s' not found on JSON object" ("f") ) ) | v -> v) .AsValue() .GetValue () |> LanguagePrimitives.FloatWithMeasure let arg_13 = (match node.["u64"] with | null -> raise ( System.Collections.Generic.KeyNotFoundException ( sprintf "Required key '%s' not found on JSON object" ("u64") ) ) | v -> v) .AsValue() .GetValue () |> LanguagePrimitives.UInt64WithMeasure let arg_12 = (match node.["u32"] with | null -> raise ( System.Collections.Generic.KeyNotFoundException ( sprintf "Required key '%s' not found on JSON object" ("u32") ) ) | v -> v) .AsValue() .GetValue () |> LanguagePrimitives.UInt32WithMeasure let arg_11 = (match node.["u"] with | null -> raise ( System.Collections.Generic.KeyNotFoundException ( sprintf "Required key '%s' not found on JSON object" ("u") ) ) | v -> v) .AsValue() .GetValue () |> LanguagePrimitives.UInt32WithMeasure let arg_10 = (match node.["i64"] with | null -> raise ( System.Collections.Generic.KeyNotFoundException ( sprintf "Required key '%s' not found on JSON object" ("i64") ) ) | v -> v) .AsValue() .GetValue () |> LanguagePrimitives.Int64WithMeasure let arg_9 = (match node.["i32"] with | null -> raise ( System.Collections.Generic.KeyNotFoundException ( sprintf "Required key '%s' not found on JSON object" ("i32") ) ) | v -> v) .AsValue() .GetValue () |> LanguagePrimitives.Int32WithMeasure let arg_8 = (match node.["i"] with | null -> raise ( System.Collections.Generic.KeyNotFoundException ( sprintf "Required key '%s' not found on JSON object" ("i") ) ) | v -> v) .AsValue() .GetValue () |> LanguagePrimitives.Int32WithMeasure let arg_7 = (match node.["sbyte"] with | null -> raise ( System.Collections.Generic.KeyNotFoundException ( sprintf "Required key '%s' not found on JSON object" ("sbyte") ) ) | v -> v) .AsValue() .GetValue () |> LanguagePrimitives.SByteWithMeasure let arg_6 = (match node.["byte"] with | null -> raise ( System.Collections.Generic.KeyNotFoundException ( sprintf "Required key '%s' not found on JSON object" ("byte") ) ) | v -> v) .AsValue() .GetValue () |> LanguagePrimitives.ByteWithMeasure let arg_5 = (match node.["arr"] with | null -> raise ( System.Collections.Generic.KeyNotFoundException ( sprintf "Required key '%s' not found on JSON object" ("arr") ) ) | v -> v) .AsArray () |> Seq.map (fun elt -> elt.AsValue().GetValue ()) |> Array.ofSeq let arg_4 = (match node.["e"] with | null -> raise ( System.Collections.Generic.KeyNotFoundException ( sprintf "Required key '%s' not found on JSON object" ("e") ) ) | v -> v) .AsArray () |> Seq.map (fun elt -> elt.AsValue().GetValue ()) |> Array.ofSeq let arg_3 = InnerTypeWithBoth.jsonParse ( match node.["d"] with | null -> raise ( System.Collections.Generic.KeyNotFoundException ( sprintf "Required key '%s' not found on JSON object" ("d") ) ) | v -> v ) let arg_2 = (match node.["c"] with | null -> raise ( System.Collections.Generic.KeyNotFoundException ( sprintf "Required key '%s' not found on JSON object" ("c") ) ) | v -> v) .AsArray () |> Seq.map (fun elt -> elt.AsValue().GetValue ()) |> List.ofSeq let arg_1 = (match node.["b"] with | null -> raise ( System.Collections.Generic.KeyNotFoundException ( sprintf "Required key '%s' not found on JSON object" ("b") ) ) | v -> v) .AsValue() .GetValue () let arg_0 = (match node.["a"] with | null -> raise ( System.Collections.Generic.KeyNotFoundException ( sprintf "Required key '%s' not found on JSON object" ("a") ) ) | v -> v) .AsValue() .GetValue () { A = arg_0 B = arg_1 C = arg_2 D = arg_3 E = arg_4 Arr = arg_5 Byte = arg_6 Sbyte = arg_7 I = arg_8 I32 = arg_9 I64 = arg_10 U = arg_11 U32 = arg_12 U64 = arg_13 F = arg_14 F32 = arg_15 Single = arg_16 } namespace ConsumePlugin /// Module containing JSON parsing extension members for the FirstDu type [] module FirstDuJsonParseExtension = /// Extension methods for JSON parsing type FirstDu with /// Parse from a JSON node. static member jsonParse (node : System.Text.Json.Nodes.JsonNode) : FirstDu = let ty = (match node.["type"] with | null -> raise ( System.Collections.Generic.KeyNotFoundException ( sprintf "Required key '%s' not found on JSON object" ("type") ) ) | v -> v) |> (fun v -> v.GetValue ()) match ty with | "emptyCase" -> FirstDu.EmptyCase | "case1" -> let node = (match node.["data"] with | null -> raise ( System.Collections.Generic.KeyNotFoundException ( sprintf "Required key '%s' not found on JSON object" ("data") ) ) | v -> v) FirstDu.Case1 ( (match node.["data"] with | null -> raise ( System.Collections.Generic.KeyNotFoundException ( sprintf "Required key '%s' not found on JSON object" ("data") ) ) | v -> v) .AsValue() .GetValue () ) | "case2" -> let node = (match node.["data"] with | null -> raise ( System.Collections.Generic.KeyNotFoundException ( sprintf "Required key '%s' not found on JSON object" ("data") ) ) | v -> v) FirstDu.Case2 ( JsonRecordTypeWithBoth.jsonParse ( match node.["record"] with | null -> raise ( System.Collections.Generic.KeyNotFoundException ( sprintf "Required key '%s' not found on JSON object" ("record") ) ) | v -> v ), (match node.["i"] with | null -> raise ( System.Collections.Generic.KeyNotFoundException ( sprintf "Required key '%s' not found on JSON object" ("i") ) ) | v -> v) .AsValue() .GetValue () ) | v -> failwith ("Unrecognised 'type' field value: " + v)