这是使用autofac
的方法var assembly = Assembly.GetExecutingAssembly();
builder.RegisterAssemblyTypes(assembly)
.Where(type => type.IsSubclassOf(typeof(Form)));
或
var assembly = Assembly.GetExecutingAssembly();
builder.RegisterAssemblyTypes(assembly)
.AssignableTo<Form>();
如何使用Castle Windsor做到这一点?
答案 0 :(得分:0)
这样的事情应该有效(从记忆中输入):
container.Register(
Classes.FromAssembly(Assembly.GetExecutingAssembly())
.BasedOn<Form>()
.Configure(c => c.Lifestyle.Transient)
);
Configure
选项并非必需,但我的获胜形式通常是暂时的。
查看registration docs了解更多选项。