@@ -595,7 +595,14 @@ public JsonSetting[] handle(object api, Dictionary<string, string> mapper)
595
595
}
596
596
else
597
597
{
598
- dArgs [ i ] = JsonConvert . DeserializeObject ( args [ i ] , types [ i ] ) ;
598
+ if ( types [ i ] . IsSubclassOf ( typeof ( Enum ) ) )
599
+ {
600
+ dArgs [ i ] = JsonConvert . DeserializeObject ( args [ i ] , types [ i ] ) ;
601
+ }
602
+ else
603
+ {
604
+ dArgs [ i ] = ProxyHandler . handler . apiMapping [ args [ i ] ] ;
605
+ }
599
606
}
600
607
601
608
}
@@ -608,7 +615,26 @@ public JsonSetting[] handle(object api, Dictionary<string, string> mapper)
608
615
}
609
616
else
610
617
{
611
- return Utils . getOne ( mapper [ "id" ] , o , null ) ;
618
+ if ( info . ReturnType . IsSubclassOf ( typeof ( Enum ) ) || Utils . isCommon ( info . ReturnType ) )
619
+ {
620
+ return Utils . getOne ( mapper [ "id" ] , o , null ) ;
621
+ }
622
+ else
623
+ {
624
+ if ( info . ReturnType == typeof ( Door [ ] ) )
625
+ {
626
+ Door [ ] doors = o as Door [ ] ;
627
+ JsonSetting [ ] settings = new JsonSetting [ doors . Length ] ;
628
+ for ( int i = 0 ; i < doors . Length ; i ++ )
629
+ {
630
+ settings [ i ] = new JsonSetting ( Lib . getInt ( mapper [ "id" ] ) , null , new IdMapping ( )
631
+ . appendId ( Lib . ID , doors [ i ] )
632
+ ) ;
633
+ }
634
+ }
635
+
636
+ return null ;
637
+ }
612
638
}
613
639
}
614
640
}
@@ -690,6 +716,7 @@ public JsonSetting[] handle(object api, Dictionary<string, string> mapper)
690
716
/**
691
717
* 可以设置基本类型值,api类型值,枚举值
692
718
* 可以返回基本类型值,枚举值
719
+ * 这个就是基于反射实现的SimpleHandler,可以阅读ProxyHandler源码
693
720
*/
694
721
public class SimpleHandler : Handler
695
722
{
@@ -711,7 +738,7 @@ public JsonSetting[] handle(object api, Dictionary<string, string> mapper)
711
738
712
739
Type returnType = obj . GetType ( ) ;
713
740
bool isCommonType = Utils . isCommon ( returnType ) ;
714
- if ( isCommonType )
741
+ if ( isCommonType || returnType . IsSubclassOf ( typeof ( Enum ) ) )
715
742
{
716
743
return Utils . getOne ( mapper [ "id" ] , obj , null ) ;
717
744
}
0 commit comments