› overview
› data types
› function matching
service.GetUser(1);
You'd rightfully think that the following method should be called:
public User GetUser(int userId){...}
The problem is that the 1 passed into AMF.NET actually comes in as a double (1.0). Since
a double can't be implicitly cast to an int, the .NET reflection engine won't find a matching
function.
IF we have less or more inputs than parameters
return false, this can't be a match
end if
if there are 0 inputs and parameters
return true, this is a match
end if
if NULL is being assigned to an object-type
go to the next parameter, so far so good
end if
if NULL is being assigned to a value-type
return false, this can't be a match
end if
if we can assign as-is
go to the next parameter, so far so good
end if
if the input is a double
AND it can be safely converted to an Int32
AND the parameter can be assigned an int
convert the input to an int
go to the next parameter, so far so good
end if
if the parameter is an array
AND the input can be an array (string[])
AND the parameter can be assigned that type
convert the input to that array
go to the next parameter, so far so good
end if
if the parameter is an enum of type Int32
AND the input can be an Int32 then
convert the input to that enum
go to the next parameter, so far so good
end if
The exact code can be seen in the private method IsMethodAMatch() of the Body class.