@@ -142,8 +142,9 @@ public virtual Task MethodBodyExecute(object key)
142142 Dictionary < string , string > formatParameters = ReflectionHelper . ParametersFormat ( _procWorker , innerMethod ) ;
143143 setWorkerStatus ( _procWorker ) ;
144144 _procWorker . cleanup ( ) ;
145+ int originalParameterCount = outputParameters . Count ;
145146 RestProcess ( _procWorker , outputParameters ) ;
146- wrapped = GetWrappedStatus ( _procWorker , wrapped , outputParameters , outputParameters . Count ) ;
147+ wrapped = GetWrappedStatus ( _procWorker , wrapped , outputParameters , outputParameters . Count , originalParameterCount ) ;
147148 return Serialize ( outputParameters , formatParameters , wrapped ) ;
148149 }
149150 catch ( Exception e )
@@ -330,9 +331,10 @@ public virtual Task MethodUrlExecute(object key)
330331 int parCount = outputParameters . Count ;
331332 setWorkerStatus ( _procWorker ) ;
332333 _procWorker . cleanup ( ) ;
334+ int originalParameterCount = outputParameters . Count ;
333335 RestProcess ( _procWorker , outputParameters ) ;
334336 bool wrapped = false ;
335- wrapped = GetWrappedStatus ( _procWorker , wrapped , outputParameters , parCount ) ;
337+ wrapped = GetWrappedStatus ( _procWorker , wrapped , outputParameters , parCount , originalParameterCount ) ;
336338 return Serialize ( outputParameters , formatParameters , wrapped ) ;
337339 }
338340 catch ( Exception e )
@@ -344,29 +346,37 @@ public virtual Task MethodUrlExecute(object key)
344346 Cleanup ( ) ;
345347 }
346348 }
347- bool GetWrappedStatus ( GXBaseObject worker , bool wrapped , Dictionary < string , object > outputParameters , int parCount )
349+ bool GetWrappedStatus ( GXBaseObject worker , bool defaultWrapped , Dictionary < string , object > outputParameters , int parCount , int originalParCount )
348350 {
351+ bool wrapped = defaultWrapped ;
349352 if ( worker . IsApiObject )
350353 {
351354 if ( outputParameters . Count == 1 )
352355 {
353- wrapped = false ;
354- Object v = outputParameters . First ( ) . Value ;
355-
356- if ( v . GetType ( ) . GetInterfaces ( ) . Contains ( typeof ( IGxGenericCollectionWrapped ) ) )
356+ if ( ( originalParCount == 1 ) || ( originalParCount > 1 && ! Preferences . WrapSingleApiOutput ) )
357357 {
358- IGxGenericCollectionWrapped icollwrapped = v as IGxGenericCollectionWrapped ;
359- if ( icollwrapped != null )
360- wrapped = icollwrapped . GetIsWrapped ( ) ;
361- }
362- if ( v is IGxGenericCollectionItem item )
363- {
364- if ( item . Sdt is GxSilentTrnSdt )
358+ wrapped = false ;
359+ Object v = outputParameters . First ( ) . Value ;
360+
361+ if ( v . GetType ( ) . GetInterfaces ( ) . Contains ( typeof ( IGxGenericCollectionWrapped ) ) )
365362 {
366- wrapped = ( parCount > 1 ) ? true : false ;
363+ IGxGenericCollectionWrapped icollwrapped = v as IGxGenericCollectionWrapped ;
364+ if ( icollwrapped != null )
365+ wrapped = icollwrapped . GetIsWrapped ( ) ;
366+ }
367+ if ( v is IGxGenericCollectionItem item )
368+ {
369+ if ( item . Sdt is GxSilentTrnSdt )
370+ {
371+ wrapped = ( parCount > 1 ) ? true : false ;
372+ }
367373 }
368374 }
369- }
375+ if ( originalParCount > 1 && Preferences . WrapSingleApiOutput )
376+ {
377+ wrapped = true ; //Ignore defaultWrapped parameter.
378+ }
379+ }
370380 }
371381 return wrapped ;
372382 }
0 commit comments