Can auto focus make partial resolution?

I need it very much.

Say I have a class with a constructor that takes a few arguments. Some of these can be resolved by registering the components. But the rest are instances created at runtime (for example, fetching an entity from a database).

Can autofac handle these situations beautifully? Or is my design not optimal?

To clarify, I have classes that have such constructors:

public MyClass(IService1 service1, IService2 service2, Data1 data1, Data2 data2)
{
//...
}

And I would like to do something like this:

container.Resolve (data1, data2);

+5
source share
2 answers

I would say that your design is not optimal.

, , . ( ) . , , , . , , , repository. , , factory . .

+3

, factory Autofac. factory, . , factory. Autofac .

. :)

+8

All Articles