tags:

views:

11

answers:

1

Does anyone knows how to workaround the fact Unity Container InjectionConstructor does not have any overload for Func<string>?

this.unityContainer .RegisterType<IService1Client, Service1Client>() .Configure<InjectedMembers>() .ConfigureInjectionFor<Service1Client>(new InjectionConstructor(() => this.unityContainer.Resolve<User>().SelectedDepartment.ApplicationServerUrl.ToString()));

Cheers,

A: 

Think I found out the answer myself:

Func<string> GetApplicationServerUrl = () => { return this.unityContainer.Resolve<User>().SelectedDepartment.ApplicationServerUrl.ToString(); }; this.unityContainer.RegisterType<IService1Client, Service1Client>().Configure<InjectedMembers>().ConfigureInjectionFor<Service1Client>(new InjectionConstructor(GetApplicationServerUrl()));

guercheLE