I have a bunch of C# functions with string, int and bool arguments that serve as data entry interfaces. I'd like to be able to create a webform for each method; a textbox for each 开发者_运维技巧string/int and a checkbox for each bool.
Is there a way to automate this process?
You'd need to use reflection to retrieve the methods' signature and then create a web form based on its parameter
// Create a container (panel for instance)
var parameters = methodInfo.GetParameters();
foreach (var parameter in parameters)
{
if (parameter.ParameterType == typeof(string))
{//Create a text box and add it to the panel}
else if (parameter.ParameterType == typeof(int))
{//Create a numeric box and add it to the panel}
...
}
精彩评论