0
interface I1{}
class Imp1: I1{}
class Imp2: I1{}
class User{
    I1 var1;
    I1 var2;
    User(I1 v1, I1 v2){
        var1 = v1;
        var2 = v2;
    }
}

So we have something like this, User has two dependencies of the same interface. By the time of declaring User instance first dependency should be strictly Imp1 type and second should be Imp2 type. Values of these two variables are going to be changed on each other during runtime depending on input actions so it's not possible to declare them as concrete implementations. And I need to use any IoC container(preferably Unity) to resolve User. So is it possible to tell the container or injector the order in which it should resolve an instance?

Steven
  • 166,672
  • 24
  • 332
  • 435

0 Answers0