private static StartupMethods PrepareStartup(IServiceCollection serviceCollection) { StartupMethods startupMethods = null; if (StartupType != null) { startupMethods = StartupLoader.LoadMethods( serviceCollection.BuildServiceProvider(), StartupType, Environment.EnvironmentName); if (typeof(IStartup).GetTypeInfo().IsAssignableFrom(StartupType.GetTypeInfo())) { serviceCollection.AddSingleton(typeof(IStartup), StartupType); } else { serviceCollection.AddSingleton(typeof(IStartup), sp => new ConventionBasedStartup(startupMethods)); } } return(startupMethods); }