/// <summary>
        /// Get all options of the type <typeparamref name="TOption"/> which have been set for the service type <paramref name="serviceType"/>
        /// or any of its derivatives.  Globally-defined options will also be included in the results unless the <see cref="EnableGlobalOptions"/>
        /// option has been set to <c>false</c> on the <paramref name="targets"/> target container.
        /// </summary>
        /// <typeparam name="TOption">The type of option to be retrieved</typeparam>
        /// <param name="targets">Required.  The target container from which the options are to be read.</param>
        /// <param name="serviceType">Required.  The service type for which options are to be retrieved.</param>
        /// <returns>An enumerable of the type <typeparamref name="TOption"/> containing zero or more options that have been
        /// set.</returns>
        public static IEnumerable <TOption> GetOptions <TOption>(this ITargetContainer targets, Type serviceType)
            where TOption : class
        {
            if (targets == null)
            {
                throw new ArgumentNullException(nameof(targets));
            }

            if (serviceType == null)
            {
                throw new ArgumentNullException(nameof(serviceType));
            }

            // global fallback in this instance causes all options - service-specific or not - to be included
            // in the enumerable.
            bool useGlobalFallback = GetOption(targets, EnableGlobalOptions.Default);

            var optionContainers = targets.FetchAllDirect(typeof(IOptionContainer <,>)
                                                          .MakeGenericType(serviceType, typeof(TOption))).Cast <IOptionContainer <TOption> >();

            if (useGlobalFallback)
            {
                optionContainers = optionContainers.Concat(targets.FetchAllDirect <IOptionContainer <TOption> >());
            }

            return(optionContainers.Select(o => o.Option));
        }
        /// <summary>
        /// Gets all globally-defined options of the type <typeparamref name="TOption"/> from the <paramref name="targets"/> target container,
        /// returning an empty enumerable if none have been set.
        /// </summary>
        /// <typeparam name="TOption">The type of option to retrieve</typeparam>
        /// <param name="targets">Required. The target container from which the options are to be read.</param>
        /// <returns>An enumerable of the type <typeparamref name="TOption"/> containing zero or more options that have been
        /// set.</returns>
        public static IEnumerable <TOption> GetOptions <TOption>(this ITargetContainer targets)
            where TOption : class
        {
            if (targets == null)
            {
                throw new ArgumentNullException(nameof(targets));
            }

            return(targets.FetchAllDirect <IOptionContainer <TOption> >().Select(o => o.Option));
        }