@@ -557,23 +557,19 @@ module TestInterfaces =
557
557
return { Brand = brand; MaxSpeed = maxSpeed; MaxLoad = maxLoad; Extra = extra }
558
558
}
559
559
560
- let ivehicleObjCodec () = codec {
561
- Car.ObjCodec () <.< (( fun ( x : Car ) -> Ok ( x :> IVehicle )) <- > fun ( x : IVehicle ) -> x :?> Car )
562
- Truck.ObjCodec () <.< (( fun ( x : Truck ) -> Ok ( x :> IVehicle )) <- > fun ( x : IVehicle ) -> x :?> Truck ) }
563
-
564
560
type Garage = { Vehicle : IVehicle } with
565
561
static member get_Codec () = ofObjCodec <| codec {
566
- let! v = jreqWith ( ofObjCodec ( ivehicleObjCodec ())) " Vehicle" ( fun x -> Some x.Vehicle)
562
+ let! v = jreq " Vehicle" ( fun x -> Some x.Vehicle)
567
563
return { Vehicle = v} }
568
564
569
565
let car = Car ( Brand = " Volvo" , MaxSpeed = 120.0 ) :> IVehicle
570
566
let truck = { Brand = " Ford" ; MaxSpeed = 100.0 ; MaxLoad = 2500.0 ; Extra = ( 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ) } :> IVehicle
571
567
let gcar = { Vehicle = car }
572
568
let gtruck = { Vehicle = truck }
573
-
574
-
575
569
576
- // do ICodecInterface<IVehicle>.RegisterCodec<AdHocEncoding, Car> Car.ObjCodec
570
+ do ICodecInterface< IVehicle>. RegisterCodec< Fleece.SystemJson.Encoding , Car> Car.ObjCodec
571
+ do ICodecInterface< IVehicle>. RegisterCodec< Fleece.Newtonsoft.Encoding , Car> Car.ObjCodec
572
+ do ICodecInterface< IVehicle>. RegisterCodec< Fleece.SystemTextJson.Encoding, Car> Car.ObjCodec
577
573
578
574
let stjGCarJson = Fleece.SystemTextJson.Operators.toJsonText gcar
579
575
let stjCarJson = Fleece.SystemTextJson.Operators.toJsonText car
@@ -583,7 +579,9 @@ module TestInterfaces =
583
579
Assert.StringContains ( " " , " brand" , stjCarJson)
584
580
Assert.StringContains ( " " , " brand" , stjGCarJson)
585
581
586
- // do ICodecInterface<IVehicle>.RegisterCodec<AdHocEncoding, Truck> Truck.ObjCodec
582
+ do ICodecInterface< IVehicle>. RegisterCodec< Fleece.SystemJson.Encoding , Truck.ObjCodec
583
+ do ICodecInterface< IVehicle>. RegisterCodec< Fleece.Newtonsoft.Encoding , Truck.ObjCodec
584
+ do ICodecInterface< IVehicle>. RegisterCodec< Fleece.SystemTextJson.Encoding, Truck.ObjCodec
587
585
588
586
let stjGTruckJson = Fleece.SystemTextJson.Operators.toJsonText gtruck
589
587
let stjTruckJson = Fleece.SystemTextJson.Operators.toJsonText truck
@@ -677,4 +675,3 @@ module TestDateTime =
677
675
let json = toJsonText x
678
676
Assert.Equal ( " DateOnly" , " \" 2022-05-22\" " , json)
679
677
#endif
680
-
0 commit comments