예제 #1
0
        /// <summary>
        /// Adds default application parts if no non-framework parts have been added.
        /// </summary>
        /// <param name="applicationPartsManager">The application part manager.</param>
        /// <returns>The application part manager.</returns>
        public static IApplicationPartManager ConfigureDefaults(this IApplicationPartManager applicationPartsManager)
        {
            var hasApplicationParts = applicationPartsManager.ApplicationParts.OfType <AssemblyPart>()
                                      .Any(part => !part.IsFrameworkAssembly);

            if (!hasApplicationParts)
            {
                applicationPartsManager.AddFromDependencyContext();
#if NETCOREAPP
                applicationPartsManager.AddFromAssemblyLoadContext();
#else
                applicationPartsManager.AddFromAppDomainWithReferences();
#endif
            }

            return(applicationPartsManager);
        }