@@ -199,6 +199,16 @@ public static object getTypeValue(string val)
199199 return val ;
200200
201201 }
202+
203+ public static bool isCommon ( Type returnType )
204+ {
205+ return returnType == typeof ( string ) || returnType == typeof ( bool ) ||
206+ returnType == typeof ( float )
207+ || returnType == typeof ( double ) || returnType == typeof ( String ) ||
208+ returnType == typeof ( Vector )
209+ || returnType == typeof ( int ) || returnType == typeof ( long ) || returnType == typeof ( char )
210+ || returnType == typeof ( byte ) || returnType == typeof ( short ) ;
211+ }
202212}
203213
204214public class HandleDo : Handler
@@ -207,6 +217,16 @@ public JsonSetting[] handle(object api, Dictionary<string, string> mapper)
207217 {
208218 Type type = api . GetType ( ) ;
209219 MethodInfo info = type . GetMethod ( mapper [ "do" ] ) ;
220+ if ( mapper . ContainsKey ( "args" ) )
221+ {
222+ string [ ] args = Lib . getArray ( mapper [ "args" ] ) ;
223+ object [ ] dArgs = new object [ args . Length ] ;
224+ for ( int i = 0 ; i < args . Length ; i ++ )
225+ {
226+ dArgs [ i ] = Utils . getTypeValue ( args [ i ] ) ;
227+ }
228+ info . Invoke ( api , dArgs ) ;
229+ }
210230 info . Invoke ( api , null ) ;
211231 return null ;
212232 }
@@ -305,12 +325,7 @@ public JsonSetting[] handle(object api, Dictionary<string, string> mapper)
305325 }
306326
307327 Type returnType = obj . GetType ( ) ;
308- bool isCommonType = returnType == typeof ( string ) || returnType == typeof ( bool ) ||
309- returnType == typeof ( float )
310- || returnType == typeof ( double ) || returnType == typeof ( String ) ||
311- returnType == typeof ( Vector )
312- || returnType == typeof ( int ) || returnType == typeof ( long ) || returnType == typeof ( char )
313- || returnType == typeof ( byte ) || returnType == typeof ( short ) ;
328+ bool isCommonType = Utils . isCommon ( returnType ) ;
314329 if ( isCommonType )
315330 {
316331 return Utils . getOne ( mapper [ "id" ] , obj , null ) ;
@@ -320,16 +335,23 @@ public JsonSetting[] handle(object api, Dictionary<string, string> mapper)
320335
321336 string fieldName = mapper [ "field" ] ;
322337 string val = mapper [ fieldName ] ;
323- object result = Utils . getTypeValue ( val ) ;
324- if ( mapper . ContainsKey ( "apiId" ) )
338+ //object result = Utils.getTypeValue(val);
339+ object result ;
340+ PropertyInfo info2 = type . GetProperty ( fieldName ) ;
341+ Type returnType2 = info2 . PropertyType ;
342+ if ( Utils . isCommon ( returnType2 ) )
325343 {
326- result = ProxyHandler . handler . apiMapping [ val ] ;
344+ result = Utils . getTypeValue ( val ) ;
327345 }
328- PropertyInfo info2 = type . GetProperty ( fieldName ) ;
329- if ( info2 != null )
346+ else
330347 {
331- info2 . SetValue ( api , result ) ;
348+ result = JsonConvert . DeserializeObject ( val , returnType2 ) ;
349+ }
350+ if ( mapper . ContainsKey ( "apiId" ) )
351+ {
352+ result = ProxyHandler . handler . apiMapping [ val ] ;
332353 }
354+ info2 . SetValue ( api , result ) ;
333355 return null ;
334356 }
335357}
0 commit comments