@@ -631,7 +631,7 @@ public override fsResult TrySerialize(object instance, out fsData serialized, Ty
631
631
}
632
632
}
633
633
634
- [ fsObject ]
634
+ [ fsObject ( Converter = typeof ( EntitiesOptionsConverter ) ) ]
635
635
public class EntitiesOptions
636
636
{
637
637
/// <summary>
@@ -650,7 +650,66 @@ public class EntitiesOptions
650
650
/// Set this to true to analyze emotion for detected keywords
651
651
/// </summary>
652
652
public bool emotion { get ; set ; }
653
+ #region Entities Options Converter
654
+ public class EntitiesOptionsConverter : fsConverter
655
+ {
656
+ private fsSerializer _serializer = new fsSerializer ( ) ;
657
+
658
+ public override bool CanProcess ( Type type )
659
+ {
660
+ return type == typeof ( EntitiesOptions ) ;
661
+ }
662
+
663
+ public override fsResult TryDeserialize ( fsData data , ref object instance , Type storageType )
664
+ {
665
+ throw new NotImplementedException ( ) ;
666
+ }
667
+
668
+ public override fsResult TrySerialize ( object instance , out fsData serialized , Type storageType )
669
+ {
670
+ EntitiesOptions entitiesOptions = ( EntitiesOptions ) instance ;
671
+ serialized = null ;
672
+
673
+ Dictionary < string , fsData > serialization = new Dictionary < string , fsData > ( ) ;
674
+
675
+ fsData tempData = null ;
676
+
677
+ if ( entitiesOptions . limit != null )
678
+ {
679
+ _serializer . TrySerialize ( entitiesOptions . limit , out tempData ) ;
680
+ serialization . Add ( "limit" , tempData ) ;
681
+ }
682
+
683
+ if ( entitiesOptions . model != null )
684
+ {
685
+ _serializer . TrySerialize ( entitiesOptions . model , out tempData ) ;
686
+ serialization . Add ( "model" , tempData ) ;
687
+ }
688
+
689
+ if ( entitiesOptions . sentiment != null )
690
+ {
691
+ _serializer . TrySerialize ( entitiesOptions . sentiment , out tempData ) ;
692
+ serialization . Add ( "sentiment" , tempData ) ;
693
+ }
694
+
695
+ if ( entitiesOptions . emotion != null )
696
+ {
697
+ _serializer . TrySerialize ( entitiesOptions . emotion , out tempData ) ;
698
+ serialization . Add ( "emotion" , tempData ) ;
699
+ }
700
+
701
+ if ( entitiesOptions . mentions != null )
702
+ {
703
+ _serializer . TrySerialize ( entitiesOptions . mentions , out tempData ) ;
704
+ serialization . Add ( "mentions" , tempData ) ;
705
+ }
706
+
707
+ serialized = new fsData ( serialization ) ;
708
+
709
+ return fsResult . Success ;
710
+ }
653
711
}
712
+ #endregion
654
713
655
714
[ fsObject ]
656
715
public class KeywordsOptions
0 commit comments