/// <summary>
        /// Loads plugins, composes DI.
        /// </summary>
        public static void RegisterApplicationServices(this Container container, AssemblyBootstrapper bootstrapper)
        {
            // Application Assemblies
            bootstrapper.RegisterDependencies(container);

            RegisterAutoMapper(container, bootstrapper);
        }
        /// <summary>
        /// Loads plugins, composes DI.
        /// </summary>
        public static void RegisterApplicationServices(
            this Container container,
            AssemblyBootstrapper bootstrapper,
            Microsoft.Extensions.Configuration.IConfiguration config)
        {
            // Application Assemblies
            bootstrapper.RegisterDependencies(container, config);

            RegisterAutoMapper(container, bootstrapper);
        }
        private static void RegisterAutoMapper(Container container, AssemblyBootstrapper bootstrapper)
        {
            var mce = new MapperConfigurationExpression();

            mce.ConstructServicesUsing(container.GetInstance);

            bootstrapper.RegisterMappingProfiles(mce);

            var mc = new MapperConfiguration(mce);

            mc.AssertConfigurationIsValid();

            container.RegisterSingleton <IMapper>(() => new Mapper(mc, container.GetInstance));
        }
        /// <summary>
        /// Loads plugins, composes DI.
        /// </summary>
        public static void RegisterApplicationServices(
            this IApplicationBuilder app,
            Container container,
            AssemblyBootstrapper bootstrapper,
            Microsoft.Extensions.Configuration.IConfiguration config)
        {
            // Application Assemblies
            bootstrapper.RegisterDependencies(container, config);

            RegisterAutoMapper(container, bootstrapper);
            container.Register <IFeatureManager, ApiFeatureManager>(Lifestyle.Singleton);

            app.UseSimpleInjector(container);
        }
        internal static IMvcBuilder AddVolleyManagementApiParts(this IMvcBuilder mvcBuilder, AssemblyBootstrapper assemblyBootstrapper, string assemblyPrefix = "VolleyM.API.")
        {
            var pluginAssemblies = assemblyBootstrapper.DiscoveredAssemblies
                                   .Where(s => s.FullName.StartsWith(assemblyPrefix, StringComparison.OrdinalIgnoreCase))
                                   .Select(a => new AssemblyPart(a))
                                   .ToList();

            Log.Information("API: {APIParts} Parts discovered.", pluginAssemblies.Count);

            return(mvcBuilder.ConfigureApplicationPartManager(apm => pluginAssemblies.ForEach(apm.ApplicationParts.Add)));
        }