var builder = new ContainerBuilder();
builder.RegisterType<SqlDAL>().Named<IDAL>("ISql");
builder.RegisterType<StudentDAL>().Named<IDAL>("IOrder");
IContainer container = builder.Build();
var sql = container.ResolveNamed<IDAL>("IOrder");
Type type = sql.GetType();
MethodInfo mInfo = type.GetMethod("insert");
mInfo.Invoke(sql, new object[] { "test" });根据Url参数调用具体的方法
最新推荐文章于 2022-10-12 11:12:27 发布
本文介绍了使用依赖注入框架注册不同类型的数据访问层,并演示了如何通过解析命名实例来调用特定实现中的方法。
255

被折叠的 条评论
为什么被折叠?



