private static Type GetImplType(this ServiceRegistration registration) { switch (registration.GetRegistryType()) { case RegistryType.ByType: return(registration.ImplementingType); case RegistryType.ByInstance: return(registration.Value.GetType()); case RegistryType.ByFactory: return(registration.FactoryExpression.Method.ReturnType); default: throw new ArgumentOutOfRangeException(); } }