internal static bool HasLifestyleMismatch(Container container, KnownRelationship relationship)
        {
            Lifestyle componentLifestyle  = relationship.Lifestyle;
            Lifestyle dependencyLifestyle = relationship.Dependency.Lifestyle;

            // If the lifestyles are the same instance, we consider them valid, even though in theory
            // an hybrid lifestyle could screw things up. In practice this would be very unlikely, since
            // the Func<bool> test delegate would typically return the same value within a given context.
            if (object.ReferenceEquals(componentLifestyle, dependencyLifestyle) &&
                componentLifestyle != Lifestyle.Unknown)
            {
                return(false);
            }

            var componentLength = componentLifestyle.ComponentLength(container);

            if (container.Options.UseLoosenedLifestyleMismatchBehavior &&
                componentLength <= Lifestyle.Scoped.Length)
            {
                return(false);
            }

            var dependencyLength = dependencyLifestyle.DependencyLength(container);

            return(componentLength > dependencyLength);
        }