/// <summary>
        /// Sets asynchronously the composition container to the ambient services.
        /// </summary>
        /// <param name="ambientServicesBuilder">The ambient services builder.</param>
        /// <param name="containerBuilderConfig">The container builder configuration.</param>
        /// <returns>A promise of the provided ambient services builder.</returns>
        public static async Task<AmbientServicesBuilder> WithMefCompositionContainerAsync(this AmbientServicesBuilder ambientServicesBuilder, Action<MefCompositionContainerBuilder> containerBuilderConfig = null)
        {
            Contract.Requires(ambientServicesBuilder != null);

            var containerBuilder = new MefCompositionContainerBuilder(new CompositionContainerBuilderContext(ambientServicesBuilder.AmbientServices));

            containerBuilderConfig?.Invoke(containerBuilder);

            var container = await containerBuilder.CreateContainerAsync().PreserveThreadContext();
            return ambientServicesBuilder.WithCompositionContainer(container);
        }
        /// <summary>
        /// Sets asynchronously the composition container to the ambient services.
        /// </summary>
        /// <param name="ambientServicesBuilder">The ambient services builder.</param>
        /// <param name="containerBuilderConfig">The container builder configuration.</param>
        /// <returns>The provided ambient services builder.</returns>
        public static async Task<AmbientServicesBuilder> WithMefCompositionContainerAsync(this AmbientServicesBuilder ambientServicesBuilder, Action<MefCompositionContainerBuilder> containerBuilderConfig = null)
        {
            Contract.Requires(ambientServicesBuilder != null);

            var containerBuilder = new MefCompositionContainerBuilder(
                ambientServicesBuilder.AmbientServices.LogManager,
                ambientServicesBuilder.AmbientServices.ConfigurationManager,
                ambientServicesBuilder.AmbientServices.PlatformManager);

            if (containerBuilderConfig != null)
            {
                containerBuilderConfig(containerBuilder);
            }

            return ambientServicesBuilder.WithCompositionContainer(await containerBuilder.CreateContainerAsync());
        }