/// <summary>
/// 执行自定义方法
/// </summary>
/// <param name="eventName"></param>
/// <returns></returns>
public object ExecuteFlowCustomEvent(string eventName, object eventParams, string dllName = "")
{
if (dllName.IsNullOrEmpty())
{
dllName = eventName.Substring(0, eventName.IndexOf('.'));
}
System.Reflection.Assembly assembly = System.Reflection.Assembly.Load(dllName);
string typeName = System.IO.Path.GetFileNameWithoutExtension(eventName);
string methodName = eventName.Substring(typeName.Length + 1);
Type type = assembly.GetType(typeName, true);
object obj = System.Activator.CreateInstance(type, true);
var method = type.GetMethod(methodName);
if (method != null)
{
return method.Invoke(obj, new object[] { eventParams });
}
else
{
throw new MissingMethodException(typeName, methodName);
}
}
强类型,动态类型解析
foreach(dynamic f in k.List)
{
IDictionary<string, Newtonsoft.Json.Linq.JToken> dic = f as IDictionary<string,Newtonsoft.Json.Linq.JToken>;
foreach(var p in dic.Keys)
{
Console.WriteLine(p);
Console.WriteLine(dic[p]);
}
}