@@ -160,7 +160,7 @@ private async Task ProcessInputBindingsAsync(IBinderEx binder, Dictionary<string
160160 stringValue = sr . ReadToEnd ( ) ;
161161 }
162162
163- // if the string input is json, convert to an object
163+ // if the input is json, try converting to an object
164164 object convertedValue = stringValue ;
165165 convertedValue = TryConvertJsonToObject ( stringValue ) ;
166166
@@ -280,13 +280,7 @@ private Dictionary<string, object> CreateScriptExecutionContext(object input, Tr
280280 { "bind" , bind }
281281 } ;
282282
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 )
290284 {
291285 // convert the request to a json object
292286 HttpRequestMessage request = ( HttpRequestMessage ) input ;
@@ -306,7 +300,7 @@ private Dictionary<string, object> CreateScriptExecutionContext(object input, Tr
306300 context [ "req" ] = requestObject ;
307301 }
308302 }
309- else if ( triggerParameterType == typeof ( TimerInfo ) )
303+ else if ( input is TimerInfo )
310304 {
311305 TimerInfo timerInfo = ( TimerInfo ) input ;
312306 var inputValues = new Dictionary < string , object > ( )
@@ -320,14 +314,25 @@ private Dictionary<string, object> CreateScriptExecutionContext(object input, Tr
320314 }
321315 input = inputValues ;
322316 }
323- else if ( typeof ( Stream ) . IsAssignableFrom ( triggerParameterType ) )
317+ else if ( input is Stream )
324318 {
325319 Stream inputStream = ( Stream ) input ;
326320 using ( StreamReader sr = new StreamReader ( inputStream ) )
327321 {
328322 input = sr . ReadToEnd ( ) ;
329323 }
330324 }
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+ }
331336
332337 bindings . Add ( _trigger . Name , input ) ;
333338
@@ -338,7 +343,7 @@ private object TryConvertJsonToObject(string input)
338343 {
339344 object result = input ;
340345
341- // if the input is json, convert to an object
346+ // if the input is json, try converting to an object
342347 Dictionary < string , object > jsonObject ;
343348 if ( TryDeserializeJsonObject ( input , out jsonObject ) )
344349 {
0 commit comments