Hi folks! I've coded myself into another corner... again! I need a guru.
This time, I'm writing code that checks that the parameter list for a call to a method is valid. Why? Because I am dynamically calling various methods with parameters read from an XML file. Why? Don't ask... looooong story.
Breifly, a call to my routine might look like
StandardTest.PerformDALvsDBTest(<br /> "DALRoutines",
Okay. So my routine goes through a bunch of checks and finally obtains a reference to the method to be called (
). The call to the method will be made using
methodRef.Invoke(null, myBindings, null, Params, null);
But first, I must make sure that all the items in the
are of the right type. To do that I loop through
and check each one against each
If there are the correct number of parameters, and they are all of the correct type, etc, then I will perform the
, otherwise, I throw an error indicating the method name, the parameter, the expected type and the type that was used:
e.g. "The System.Type for parameter #0 in the parameter list for the method [DALRoutines.InsertCustomer] is System.DateTime; System.TimeSpan was expected
So, here is my problem:
I have a method that expects a parameter to be an
. However, when the value is passed in the
, it seems to be changed to
(even if I specifically indicate that it is
as above - I assume that it is because it is a small value). When my routine starts comparing parameter types it spits out an error saying it was passed an
when it expects an
. The kicker is that the call to
would still work if it was made - .NET does not seem to mind and handles the conversion inherently. But I can't find a way to tell that it would work - all I can see is that the two types are different.
I have tried investigating different ways to tell if the types are compatible (including
) but I can't seem to find anything that will let me know that an
can be used as the value for an
Does anyone know a way to do this?