I have a xml as below:
I've done something broadly similar for a project I'm working on. From a high level perspective, if you can assume that the Action Word is exactly the name of a method in some assembly, then you can use reflection to get a MethodInfo corresponding to the actual function. You can then invoke the function, passing in the appropriate parameters to the method.
The one catch here is how to specify the parameters. Since there will be a variable number of parameters, you need to use a data structure which is capable of handling the variable list. I'd suggest using a Dictionary to pass the parameters.
Ok, so assuming that you can identify and load the appropriate assembly, proceed something like this:
foreach Action:
It takes as much prose to describe as it does code to implement. One of the harder things, at least as I find it, is to load or access the Type of the Assembly which contains the methods. Also, it would probably be best to implement the methods as static, so that you don't have to be concerned about creating an instance of the handler class.
object obj = this; //your object containing methods
XDocument xDoc = XDocument.Parse(xml);
Type type = obj.GetType();
foreach (var action in xDoc.Descendants("Action"))
{
MethodInfo mi = type.GetMethod(action.Attribute("Word").Value);
var dict = action.Descendants().ToDictionary(
d=>d.Attribute("Name").Value,
d=>d.Attribute("Value").Value);
object[] parameters = mi.GetParameters()
.Select(p => Convert.ChangeType(dict[p.Name],p.ParameterType))
.ToArray();
var expectedResult = mi.Invoke(obj, parameters);
Debug.Assert(expectedResult.Equals(dict["expectedResult"]));
}