/// <summary>
        /// Launch the user interface for developer to pick a contract type.
        /// </summary>
        /// <param name="localAssemblyName">The local assembly name.</param>
        /// <param name="referencedAssemblies">The list of referenced assembly names.</param>
        /// <param name="editingContext">The editing context.</param>
        /// <returns>The contract type selected by user or null if user cancels.</returns>
        public static Type SelectContractType(AssemblyName localAssemblyName, IList <AssemblyName> referencedAssemblies, EditingContext editingContext)
        {
            AssemblyContextControlItem assemblyContextControlItem = new AssemblyContextControlItem {
                LocalAssemblyName = localAssemblyName, ReferencedAssemblyNames = referencedAssemblies
            };
            TypeBrowser typeBrowser  = new TypeBrowser(assemblyContextControlItem, editingContext, FilterFunction);
            bool?       dialogResult = typeBrowser.ShowDialog(/* owner = */ null);

            if (dialogResult.HasValue && dialogResult.Value)
            {
                return(typeBrowser.ConcreteType);
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        /// Retrieves and returns the selected type from the user.
        /// </summary>
        /// <param name="selectedType">The type to select in the type selection dialog.</param>
        /// <param name="baseType">The base type (class or interface) from which the constrained type should derive.</param>
        /// <param name="selectorIncludes">Indicates the types that can be browsed.</param>
        /// <param name="configurationType">The base type from which a type specified by the
        /// <see cref="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationElementTypeAttribute"/>
        /// bound to the constrained type should derive, or <see langword="null"/> if no such constraint is necessary.
        /// </param>
        /// <returns>
        /// The selected <see cref="Type"/> or <see langword="null"/> if not type is selected.
        /// </returns>
        protected virtual Type GetSelectedType(Type selectedType, Type baseType, TypeSelectorIncludes selectorIncludes, Type configurationType)
        {
            var viewModel = new TypeBrowserViewModel(new TypeBuildNodeConstraint(baseType, configurationType, selectorIncludes), this);
            var selector  = new TypeBrowser(viewModel, this.discoveryService);

            Nullable <bool> result = false;

            if (this.UIService != null)
            {
                result = UIService.ShowDialog(selector);
            }
            else
            {
                result = selector.ShowDialog();
            }

            if (result.HasValue && result.Value)
            {
                return(selector.SelectedType);
            }
            return(null);
        }