Integration Crm Integration Crm - 1 year ago 154
ASP.NET (C#) Question

Structure Map ObjectFactory.GetAllInstances Scope

I've come across some code in the Application_EndRequest event and I'm trying to work out how it will behave:

var services = ObjectFactory.GetAllInstances<IService>();

Does this return all instances in the container? Given that there is a single container for the application, and a per request scope, does this mean this will return all instances for active requests?

However, I've put some logging in and sent multiple simultaneous requests and this count is only ever 1

Answer Source

ObjectFactory.GetAllInstances<IService>(); returns all implementations of IService registered in the container. If it returns just one instance that means only one type is registered.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download