문제

This is the way how to do it with autofac

var assembly = Assembly.GetExecutingAssembly();
builder.RegisterAssemblyTypes(assembly)
    .Where(type => type.IsSubclassOf(typeof(Form)));

or

var assembly = Assembly.GetExecutingAssembly();
builder.RegisterAssemblyTypes(assembly)
    .AssignableTo<Form>();

How to do this with Castle Windsor ?

도움이 되었습니까?

해결책

Something like this should work (typing from memory):

container.Register(
   Classes.FromAssembly(Assembly.GetExecutingAssembly())
      .BasedOn<Form>()
      .Configure(c => c.Lifestyle.Transient)
);

The Configure option isn't required, but my win forms are usually transient.

Check out the registration docs for more options.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top