@@ -160,7 +160,7 @@ private async Task ProcessInputBindingsAsync(IBinderEx binder, Dictionary<string
160
160
stringValue = sr . ReadToEnd ( ) ;
161
161
}
162
162
163
- // if the string input is json, convert to an object
163
+ // if the input is json, try converting to an object
164
164
object convertedValue = stringValue ;
165
165
convertedValue = TryConvertJsonToObject ( stringValue ) ;
166
166
@@ -280,13 +280,7 @@ private Dictionary<string, object> CreateScriptExecutionContext(object input, Tr
280
280
{ "bind" , bind }
281
281
} ;
282
282
283
- Type triggerParameterType = input . GetType ( ) ;
284
- if ( triggerParameterType == typeof ( string ) )
285
- {
286
- // if the input is json, convert to an object
287
- input = TryConvertJsonToObject ( ( string ) input ) ;
288
- }
289
- else if ( triggerParameterType == typeof ( HttpRequestMessage ) )
283
+ if ( input is HttpRequestMessage )
290
284
{
291
285
// convert the request to a json object
292
286
HttpRequestMessage request = ( HttpRequestMessage ) input ;
@@ -306,7 +300,7 @@ private Dictionary<string, object> CreateScriptExecutionContext(object input, Tr
306
300
context [ "req" ] = requestObject ;
307
301
}
308
302
}
309
- else if ( triggerParameterType == typeof ( TimerInfo ) )
303
+ else if ( input is TimerInfo )
310
304
{
311
305
TimerInfo timerInfo = ( TimerInfo ) input ;
312
306
var inputValues = new Dictionary < string , object > ( )
@@ -320,14 +314,25 @@ private Dictionary<string, object> CreateScriptExecutionContext(object input, Tr
320
314
}
321
315
input = inputValues ;
322
316
}
323
- else if ( typeof ( Stream ) . IsAssignableFrom ( triggerParameterType ) )
317
+ else if ( input is Stream )
324
318
{
325
319
Stream inputStream = ( Stream ) input ;
326
320
using ( StreamReader sr = new StreamReader ( inputStream ) )
327
321
{
328
322
input = sr . ReadToEnd ( ) ;
329
323
}
330
324
}
325
+ else
326
+ {
327
+ // TODO: Handle case where the input type is something
328
+ // that we can't convert properly
329
+ }
330
+
331
+ if ( input is string )
332
+ {
333
+ // if the input is json, try converting to an object
334
+ input = TryConvertJsonToObject ( ( string ) input ) ;
335
+ }
331
336
332
337
bindings . Add ( _trigger . Name , input ) ;
333
338
@@ -338,7 +343,7 @@ private object TryConvertJsonToObject(string input)
338
343
{
339
344
object result = input ;
340
345
341
- // if the input is json, convert to an object
346
+ // if the input is json, try converting to an object
342
347
Dictionary < string , object > jsonObject ;
343
348
if ( TryDeserializeJsonObject ( input , out jsonObject ) )
344
349
{
0 commit comments