private static ApplicationPartManager GetApplicationPartManager(IServiceCollection services, IWebHostEnvironment?environment)
    {
        var manager = GetServiceFromCollection <ApplicationPartManager>(services);

        if (manager == null)
        {
            manager = new ApplicationPartManager();

            var entryAssemblyName = environment?.ApplicationName;
            if (string.IsNullOrEmpty(entryAssemblyName))
            {
                return(manager);
            }

            manager.PopulateDefaultParts(entryAssemblyName);
        }

        return(manager);
    }