1

I have registered following types with IOC (func) in App host.Classes & interfaces given below are in a separate class library .This class library contains a WCF service reference .

private void RegisteTyeps(Container container)
        {

            //Register Mapper
            container.Register<IMapper>(c => _mapperConfiguration.CreateMapper());


            container.RegisterAutoWiredAs<AppointmentHandler, IAppointmentHandler>().ReusedWithin(ReuseScope.Container);
            container.RegisterAutoWiredAs<CalendarHandler, ICalendarHandler>().ReusedWithin(ReuseScope.Container);
            container.RegisterAutoWiredAs<SettingHandler, ISettingHandler>().ReusedWithin(ReuseScope.Container);

        }

I wanted to add some more service references (Which are slightly different than each other ) and generate proxies.Thus i added some more class libraries with respective service references .Each class libraries contains "same" interface and classe as mentioned above .

I wanted to dynamically load /Switch class library based on request header or something so that i can only use particular library which has the appropriate service reference & proxies.

How can i achieve this with service stack .Any one have any idea?

Thabo
  • 1,492
  • 2
  • 18
  • 36

1 Answers1

1

You can only register a dependency against a single Type or Interface in Funq. If you want to perform multiple registrations you would either need to register a Factory type, e.g:

container.Register(c => new AppointmentHandlers(
     new AppointmentHandler1(),
     new AppointmentHandler2());

Then resolve it with:

public AppointmentHandlers AppointmentHandlers { get; set; }

public object Any(MyRequest request)
{
     var dep = AppointmentHandlers.AppointmentHandler1();
}

Otherwise you need to register them with different interfaces or use a named registration.

mythz
  • 141,670
  • 29
  • 246
  • 390