Closed msironi closed 13 years ago
Fixed it by changing the method body as follows:
private IFactory GetDefaultFactory(string serviceName, Type serviceType, IFactory factory) { var defaultNamedServiceInfo = new ServiceInfo(serviceName, serviceType); if (factory == null && base.ContainsFactory(defaultNamedServiceInfo)) factory = base.GetFactory(defaultNamedServiceInfo);
if (serviceType.IsGenericType)
{
var defaultServiceInfo = new ServiceInfo(string.Empty, serviceType);
if (factory == null && base.ContainsFactory(defaultServiceInfo))
factory = base.GetFactory(defaultServiceInfo);
}
return factory;
}
Not sure if this is a but or a feature, but it is a change from how LinFu used to work (I have a unit test that started failing with a trunk pull from yesterday).
With the latest LinFu trunk, services added to a container as unnamed services get returned for service queries for a named service. For example:
The second Assert used to pass it now asserts as the GetService("frobozz") call is returning the unnamed instance.
I suspect this was introduced by the fix for my earlier problem with factories for generic types (although I haven't debugged LinFu to figure out why this started happening).
EDIT: The second if in FactoryStorage.GetDefaultFactory() is what is doing it. And I was right it's part of the changeset for the fix to my earlier generics bug.