@@ -13,7 +13,7 @@ namespace BTDB.Serialization;
13
13
14
14
public delegate void Serialize ( ref SerializerCtx ctx , ref byte value ) ;
15
15
16
- public delegate void Deserialize ( ref DeserializerCtx ctx , ref byte value ) ;
16
+ public delegate bool Deserialize ( ref DeserializerCtx ctx , ref byte value ) ;
17
17
18
18
public interface ISerializerFactory
19
19
{
@@ -502,6 +502,7 @@ public Deserialize CreateCachedDeserializerForType(Type type)
502
502
return ( ref DeserializerCtx ctx , ref byte value ) =>
503
503
{
504
504
Unsafe. As < byte , object > ( ref value ) = AsCtx( ref ctx ) . Factory . DeserializeObject ( ref ctx ) ;
505
+ return true;
505
506
} ;
506
507
}
507
508
@@ -549,7 +550,7 @@ public Deserialize CreateCachedDeserializerForType(Type type)
549
550
}
550
551
case BonType. Tuple :
551
552
{
552
- AsCtx( ref ctx ) . Bon . TryGetArray ( out var arrayBon ) ;
553
+ AsCtx( ref ctx ) . Bon . TryGetTuple ( out var arrayBon ) ;
553
554
arrayBon. TryGet ( 0 , out var itemBon ) ;
554
555
var count = arrayBon. Items ;
555
556
if ( count == 2 )
@@ -650,7 +651,11 @@ public Deserialize CreateCachedDeserializerForName(ReadOnlySpan<byte> name)
650
651
return deserializer ! ;
651
652
}
652
653
653
- return ( ref DeserializerCtx ctx , ref byte value ) => { AsCtx ( ref ctx ) . Bon . Skip ( ) ; } ;
654
+ return ( ref DeserializerCtx ctx , ref byte _ ) =>
655
+ {
656
+ AsCtx ( ref ctx ) . Bon . Skip ( ) ;
657
+ return false;
658
+ } ;
654
659
}
655
660
656
661
public Deserialize CreateDeserializerForType ( Type type )
@@ -659,8 +664,16 @@ public Deserialize CreateDeserializerForType(Type type)
659
664
{
660
665
return static ( ref DeserializerCtx ctx , ref byte value ) =>
661
666
{
662
- if ( ! AsCtx ( ref ctx ) . Bon . TryGetString ( out Unsafe . As < byte , string > ( ref value ) ) )
667
+ if ( AsCtx ( ref ctx ) . Bon . TryGetString ( out var v ) )
668
+ {
669
+ Unsafe . As < byte , string > ( ref value ) = v;
670
+ return true ;
671
+ }
672
+ else
673
+ {
663
674
AsCtx ( ref ctx ) . Bon . Skip ( ) ;
675
+ return false ;
676
+ }
664
677
} ;
665
678
}
666
679
@@ -671,10 +684,12 @@ public Deserialize CreateDeserializerForType(Type type)
671
684
if ( AsCtx ( ref ctx ) . Bon . TryGetULong ( out var v ) )
672
685
{
673
686
value = ( byte ) v ;
687
+ return true;
674
688
}
675
689
else
676
690
{
677
691
AsCtx( ref ctx ) . Bon . Skip ( ) ;
692
+ return false;
678
693
}
679
694
} ;
680
695
}
@@ -686,10 +701,12 @@ public Deserialize CreateDeserializerForType(Type type)
686
701
if ( AsCtx ( ref ctx ) . Bon . TryGetLong ( out var v ) )
687
702
{
688
703
Unsafe. As < byte , sbyte > ( ref value ) = ( sbyte ) v ;
704
+ return true;
689
705
}
690
706
else
691
707
{
692
708
AsCtx ( ref ctx ) . Bon . Skip ( ) ;
709
+ return false;
693
710
}
694
711
} ;
695
712
}
@@ -701,10 +718,12 @@ public Deserialize CreateDeserializerForType(Type type)
701
718
if ( AsCtx ( ref ctx ) . Bon . TryGetULong ( out var v ) )
702
719
{
703
720
Unsafe . As < byte , ushort > ( ref value ) = ( ushort ) v ;
721
+ return true ;
704
722
}
705
723
else
706
724
{
707
725
AsCtx ( ref ctx ) . Bon . Skip ( ) ;
726
+ return false ;
708
727
}
709
728
} ;
710
729
}
@@ -716,10 +735,12 @@ public Deserialize CreateDeserializerForType(Type type)
716
735
if ( AsCtx ( ref ctx ) . Bon . TryGetLong ( out var v ) )
717
736
{
718
737
Unsafe. As < byte , short > ( ref value ) = ( short ) v ;
738
+ return true;
719
739
}
720
740
else
721
741
{
722
742
AsCtx ( ref ctx ) . Bon . Skip ( ) ;
743
+ return false;
723
744
}
724
745
} ;
725
746
}
@@ -731,10 +752,12 @@ public Deserialize CreateDeserializerForType(Type type)
731
752
if ( AsCtx ( ref ctx ) . Bon . TryGetULong ( out var v ) )
732
753
{
733
754
Unsafe . As < byte , uint > ( ref value ) = ( uint ) v ;
755
+ return true ;
734
756
}
735
757
else
736
758
{
737
759
AsCtx ( ref ctx ) . Bon . Skip ( ) ;
760
+ return false ;
738
761
}
739
762
} ;
740
763
}
@@ -746,10 +769,12 @@ public Deserialize CreateDeserializerForType(Type type)
746
769
if ( AsCtx ( ref ctx ) . Bon . TryGetLong ( out var v ) )
747
770
{
748
771
Unsafe. As < byte , int > ( ref value ) = ( int ) v ;
772
+ return true;
749
773
}
750
774
else
751
775
{
752
776
AsCtx ( ref ctx ) . Bon . Skip ( ) ;
777
+ return false;
753
778
}
754
779
} ;
755
780
}
@@ -761,10 +786,12 @@ public Deserialize CreateDeserializerForType(Type type)
761
786
if ( AsCtx ( ref ctx ) . Bon . TryGetULong ( out var v ) )
762
787
{
763
788
Unsafe . As < byte , ulong > ( ref value ) = v;
789
+ return true ;
764
790
}
765
791
else
766
792
{
767
793
AsCtx ( ref ctx ) . Bon . Skip ( ) ;
794
+ return false ;
768
795
}
769
796
} ;
770
797
}
@@ -776,10 +803,12 @@ public Deserialize CreateDeserializerForType(Type type)
776
803
if ( AsCtx ( ref ctx ) . Bon . TryGetLong ( out var v ) )
777
804
{
778
805
Unsafe. As < byte , long > ( ref value ) = v;
806
+ return true;
779
807
}
780
808
else
781
809
{
782
810
AsCtx( ref ctx ) . Bon . Skip ( ) ;
811
+ return false;
783
812
}
784
813
} ;
785
814
}
@@ -791,10 +820,12 @@ public Deserialize CreateDeserializerForType(Type type)
791
820
if ( AsCtx ( ref ctx ) . Bon . TryGetDouble ( out var v ) )
792
821
{
793
822
Unsafe. As < byte , float > ( ref value ) = ( float ) v ;
823
+ return true;
794
824
}
795
825
else
796
826
{
797
827
AsCtx ( ref ctx ) . Bon . Skip ( ) ;
828
+ return false;
798
829
}
799
830
} ;
800
831
}
@@ -806,10 +837,12 @@ public Deserialize CreateDeserializerForType(Type type)
806
837
if ( AsCtx ( ref ctx ) . Bon . TryGetDouble ( out var v ) )
807
838
{
808
839
Unsafe . As < byte , double > ( ref value ) = v;
840
+ return true ;
809
841
}
810
842
else
811
843
{
812
844
AsCtx ( ref ctx ) . Bon . Skip ( ) ;
845
+ return false ;
813
846
}
814
847
} ;
815
848
}
@@ -821,10 +854,12 @@ public Deserialize CreateDeserializerForType(Type type)
821
854
if ( AsCtx ( ref ctx ) . Bon . TryGetBool ( out var v ) )
822
855
{
823
856
Unsafe. As < byte , bool > ( ref value ) = v;
857
+ return true;
824
858
}
825
859
else
826
860
{
827
861
AsCtx( ref ctx ) . Bon . Skip ( ) ;
862
+ return false;
828
863
}
829
864
} ;
830
865
}
@@ -836,10 +871,12 @@ public Deserialize CreateDeserializerForType(Type type)
836
871
if ( AsCtx ( ref ctx ) . Bon . TryGetDateTime ( out var v ) )
837
872
{
838
873
Unsafe. As < byte , DateTime > ( ref value ) = v;
874
+ return true;
839
875
}
840
876
else
841
877
{
842
878
AsCtx( ref ctx ) . Bon . Skip ( ) ;
879
+ return false;
843
880
}
844
881
} ;
845
882
}
@@ -851,10 +888,12 @@ public Deserialize CreateDeserializerForType(Type type)
851
888
if ( AsCtx ( ref ctx ) . Bon . TryGetGuid ( out var v ) )
852
889
{
853
890
Unsafe. As < byte , Guid > ( ref value ) = v;
891
+ return true;
854
892
}
855
893
else
856
894
{
857
895
AsCtx( ref ctx ) . Bon . Skip ( ) ;
896
+ return false;
858
897
}
859
898
} ;
860
899
}
@@ -866,10 +905,12 @@ public Deserialize CreateDeserializerForType(Type type)
866
905
if ( AsCtx ( ref ctx ) . Bon . TryGetDouble ( out var v ) )
867
906
{
868
907
Unsafe. As < byte , Half > ( ref value ) = ( Half ) v;
908
+ return true;
869
909
}
870
910
else
871
911
{
872
912
AsCtx( ref ctx ) . Bon . Skip ( ) ;
913
+ return false;
873
914
}
874
915
} ;
875
916
}
0 commit comments