private static int AdaptClassServices(Type closedImplementationType, List<Type> closedServices, Type[] openServices)
{
var index = 0;
// we split the check into two parts: first we inspect class services...
var genericDefinitionToClass = default(IDictionary<Type, Type>);
while (index < openServices.Length && openServices[index].IsClass)
{
var service = openServices[index];
if (service.IsGenericTypeDefinition)
{
EnsureClassMappingInitialized(closedImplementationType, ref genericDefinitionToClass);
Type closed;
if (genericDefinitionToClass.TryGetValue(service, out closed))
{
closedServices.Add(closed);
}
#if !SILVERLIGHT
else
{
// NOTE: it's an interface not exposed by the implementation type. Possibly aimed at a proxy... I guess we can ignore it for now. Don't have any better idea.
Debug.Fail(string.Format("Could not find mapping for interface {0} on implementation type {1}", service, closedImplementationType));
}
#endif
}
else
{
closedServices.Add(service);
}
index++;
}
return index;
}