码迷,mamicode.com
首页 > 其他好文 > 详细

反射动态调用子类方法

时间:2017-05-06 20:00:07      阅读:208      评论:0      收藏:0      [点我收藏+]

标签:var   message   类方法   func   handle   creat   string   type   domain   

//Type type = Type.GetType("Domain.Entitiy." + item.Name);
//object handler = Activator.CreateInstance(type);
//Func<string, QueryStoresOutput> hook = o => ((dynamic)handler).QueryStore((dynamic)o);
//var res = hook(cityCode);


  Type type = Type.GetType("Domain.Entitiy." + item.Name);
  object handler = Activator.CreateInstance(type);
  Func<BusinessSystemSubmitInputModel, QuoteSnapshot> hook =
      o => ((dynamic)handler).GetQuote((dynamic)o);
  var res = hook(model);

 

 

Action<object> hook = message => ((dynamic)handler).HandleMessage((dynamic)message);

反射动态调用子类方法

标签:var   message   类方法   func   handle   creat   string   type   domain   

原文地址:http://www.cnblogs.com/kevin1988/p/6817705.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!