public override bool Execute() { try { var bootstrapFileType = ParseFileType(FileType); Log.LogMessage(MessageImportance.Normal, $"{LogPrefix}Reading content of {bootstrapFileType} file '{FilePath}'"); var fileLines = File.ReadAllLines(FilePath).ToList(); var bootstrapper = BootstrapperFactory.GetBootstrapper(bootstrapFileType); if (bootstrapper.Bootstrap(fileLines)) { File.WriteAllLines(FilePath, fileLines); Log.LogMessage(MessageImportance.Normal, $"{LogPrefix}Bootstrapping completed for {bootstrapFileType} file '{FilePath}'"); } else { Log.LogMessage(MessageImportance.Normal, $"{LogPrefix}Bootstrapping skipped for {bootstrapFileType} file '{FilePath}'"); } return(true); } catch (Exception ex) { Log.LogError($"{LogPrefix}An unexpected error occured when bootstrapping file '{FilePath}'"); Log.LogErrorFromException(ex); return(false); } }
public static void Register() { DIContainer.Current.Register <WebApplicationStartup>(); // Manual Simplify.Web bootstrapper registration BootstrapperFactory.CreateBootstrapper().Register(); }
internal async Task Create_TemplateWithBinaryFile_Package() { Console.WriteLine(System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription); using Bootstrapper bootstrapper = BootstrapperFactory.GetBootstrapper(); string packageLocation = _packageManager.PackTestTemplatesNuGetPackage(); await bootstrapper.InstallTemplateAsync(packageLocation).ConfigureAwait(false); string templateLocation = TestUtils.GetTestTemplateLocation("TemplateWithBinaryFile"); string output = TestUtils.CreateTemporaryFolder(); var foundTemplates = await bootstrapper.GetTemplatesAsync(new[] { WellKnownSearchFilters.NameFilter("TestAssets.TemplateWithBinaryFile") }).ConfigureAwait(false); var result = await bootstrapper.CreateAsync(foundTemplates[0].Info, "my-test-folder", output, new Dictionary <string, string>()).ConfigureAwait(false); string sourceImage = Path.Combine(templateLocation, "image.png"); string targetImage = Path.Combine(output, "image.png"); Assert.True(File.Exists(targetImage)); Assert.Equal( new FileInfo(sourceImage).Length, new FileInfo(targetImage).Length); Assert.True(TestUtils.CompareFiles(sourceImage, targetImage), $"The content of {sourceImage} and {targetImage} is not same."); }
internal async Task GetCreationEffects_BasicTest_Package() { using Bootstrapper bootstrapper = BootstrapperFactory.GetBootstrapper(); string packageLocation = await _packageManager.GetNuGetPackage("Microsoft.DotNet.Common.ProjectTemplates.5.0").ConfigureAwait(false); await bootstrapper.InstallTemplateAsync(packageLocation).ConfigureAwait(false); string output = TestUtils.CreateTemporaryFolder(); var foundTemplates = await bootstrapper.GetTemplatesAsync(new[] { WellKnownSearchFilters.NameFilter("console") }).ConfigureAwait(false); var result = await bootstrapper.GetCreationEffectsAsync(foundTemplates[0].Info, "test", output, new Dictionary <string, string>(), "").ConfigureAwait(false); Assert.Equal(2, result.CreationResult.PrimaryOutputs.Count); Assert.Equal(2, result.CreationResult.PostActions.Count); Assert.Equal(2, result.FileChanges.Count); var expectedFileChanges = new FileChange[] { new FileChange("Company.ConsoleApplication1.csproj", "test.csproj", ChangeKind.Create), new FileChange("Program.cs", "Program.cs", ChangeKind.Create), }; IFileChangeComparer comparer = new IFileChangeComparer(); Assert.Equal( expectedFileChanges.OrderBy(s => s, comparer), result.FileChanges.OrderBy(s => s, comparer), comparer); }
internal async Task CanUninstall_NuGetPackage() { using Bootstrapper bootstrapper = BootstrapperFactory.GetBootstrapper(); InstallRequest installRequest = new InstallRequest("Microsoft.DotNet.Common.ProjectTemplates.5.0", "5.0.0"); IReadOnlyList <InstallResult> result = await bootstrapper.InstallTemplatePackagesAsync(new[] { installRequest }, InstallationScope.Global, CancellationToken.None).ConfigureAwait(false); Assert.Equal(1, result.Count); Assert.True(result[0].Success); IManagedTemplatePackage source = result[0].TemplatePackage; IReadOnlyList <IManagedTemplatePackage> managedTemplatesPackages = await bootstrapper.GetManagedTemplatePackages(CancellationToken.None).ConfigureAwait(false); Assert.Equal(1, managedTemplatesPackages.Count); managedTemplatesPackages[0].Should().BeEquivalentTo(source); IReadOnlyList <UninstallResult> uninstallResults = await bootstrapper.UninstallTemplatePackagesAsync(new[] { source }, CancellationToken.None).ConfigureAwait(false); Assert.Equal(1, uninstallResults.Count); Assert.True(uninstallResults[0].Success); Assert.Equal(InstallerErrorCode.Success, uninstallResults[0].Error); uninstallResults[0].ErrorMessage.Should().BeNullOrEmpty(); Assert.Equal(source, uninstallResults[0].TemplatePackage); IReadOnlyList <ITemplatePackage> templatePackages = await bootstrapper.GetTemplatePackages(CancellationToken.None).ConfigureAwait(false); Assert.Equal(0, templatePackages.Count); }
internal async Task GetCreationEffectsTest(string templateName, string parameters, MockCreationEffects expectedResult) { Bootstrapper bootstrapper = BootstrapperFactory.GetBootstrapper(); bootstrapper.InstallTestTemplate(templateName); string name = BasicParametersParser.GetNameFromParameterString(parameters); string output = BasicParametersParser.GetOutputFromParameterString(parameters); Dictionary <string, string> parametersDict = BasicParametersParser.ParseParameterString(parameters); ITemplateInfo template = bootstrapper.ListTemplates(true, WellKnownSearchFilters.NameFilter(templateName)).First().Info; ICreationEffects result = await bootstrapper.GetCreationEffectsAsync(template, name, output, parametersDict, "").ConfigureAwait(false); Assert.Equal(expectedResult.CreationResult.PrimaryOutputs.Count, result.CreationResult.PrimaryOutputs.Count); Assert.Equal( expectedResult.CreationResult.PrimaryOutputs.Select(po => po.Path).OrderBy(s => s, StringComparer.OrdinalIgnoreCase), result.CreationResult.PrimaryOutputs.Select(po => po.Path).OrderBy(s => s, StringComparer.OrdinalIgnoreCase), StringComparer.OrdinalIgnoreCase); IFileChangeComparer comparer = new IFileChangeComparer(); Assert.Equal(expectedResult.FileChanges.Count, result.FileChanges.Count); Assert.Equal( expectedResult.FileChanges.OrderBy(s => s, comparer), result.FileChanges.OrderBy(s => s, comparer), comparer); }
internal async Task CanInstall_Folder() { using Bootstrapper bootstrapper = BootstrapperFactory.GetBootstrapper(); string templateLocation = TestUtils.GetTestTemplateLocation("TemplateWithSourceName"); InstallRequest installRequest = new InstallRequest(Path.GetFullPath(templateLocation)); IReadOnlyList <InstallResult> result = await bootstrapper.InstallTemplatePackagesAsync(new[] { installRequest }, InstallationScope.Global, CancellationToken.None).ConfigureAwait(false); Assert.Equal(1, result.Count); Assert.True(result[0].Success); Assert.Equal(InstallerErrorCode.Success, result[0].Error); result[0].ErrorMessage.Should().BeNullOrEmpty(); Assert.Equal(installRequest, result[0].InstallRequest); IManagedTemplatePackage source = result[0].TemplatePackage; Assert.Equal(Path.GetFullPath(templateLocation), source.Identifier); Assert.Equal("Global Settings", source.Provider.Factory.DisplayName); Assert.Equal("Folder", source.Installer.Factory.Name); source.Version.Should().BeNullOrEmpty(); IReadOnlyList <IManagedTemplatePackage> managedTemplatesPackages = await bootstrapper.GetManagedTemplatePackages(CancellationToken.None).ConfigureAwait(false); Assert.Equal(1, managedTemplatesPackages.Count); managedTemplatesPackages[0].Should().BeEquivalentTo(source); IReadOnlyList <ITemplatePackage> templatePackages = await bootstrapper.GetTemplatePackages(CancellationToken.None).ConfigureAwait(false); Assert.Equal(1, templatePackages.Count); Assert.IsAssignableFrom <IManagedTemplatePackage>(templatePackages[0]); templatePackages[0].Should().BeEquivalentTo((ITemplatePackage)source); }
internal async Task GetCreationEffects_BasicTest_Package() { var bootstrapper = BootstrapperFactory.GetBootstrapper(); string packageLocation = _packageManager.PackProjectTemplatesNuGetPackage("microsoft.dotnet.common.projecttemplates.5.0"); bootstrapper.InstallTemplate(packageLocation); string output = TestHelper.CreateTemporaryFolder(); var template = bootstrapper.ListTemplates(true, WellKnownSearchFilters.NameFilter("console")); var result = await bootstrapper.GetCreationEffectsAsync(template.First().Info, "test", output, new Dictionary <string, string>(), "").ConfigureAwait(false); Assert.Equal(2, result.CreationResult.PrimaryOutputs.Count); Assert.Equal(2, result.CreationResult.PostActions.Count); Assert.Equal(2, result.FileChanges.Count); var expectedFileChanges = new FileChange[] { new FileChange("Company.ConsoleApplication1.csproj", "test.csproj", ChangeKind.Create), new FileChange("Program.cs", "Program.cs", ChangeKind.Create), }; IFileChangeComparer comparer = new IFileChangeComparer(); Assert.Equal( expectedFileChanges.OrderBy(s => s, comparer), result.FileChanges.OrderBy(s => s, comparer), comparer); }
internal async Task GetCreationEffectsTest_Package(string templateName, string parameters, MockCreationEffects expectedResult) { using Bootstrapper bootstrapper = BootstrapperFactory.GetBootstrapper(); string packageLocation = _packageManager.PackTestTemplatesNuGetPackage(); await bootstrapper.InstallTemplateAsync(packageLocation).ConfigureAwait(false); string name = BasicParametersParser.GetNameFromParameterString(parameters); string output = BasicParametersParser.GetOutputFromParameterString(parameters); Dictionary <string, string> parametersDict = BasicParametersParser.ParseParameterString(parameters); var foundTemplates = await bootstrapper.GetTemplatesAsync(new[] { WellKnownSearchFilters.NameFilter(templateName) }).ConfigureAwait(false); ITemplateInfo template = foundTemplates.Single(template => template.Info.ShortNameList.Contains($"TestAssets.{templateName}")).Info; ICreationEffects result = await bootstrapper.GetCreationEffectsAsync(template, name, output, parametersDict, "").ConfigureAwait(false); Assert.Equal(expectedResult.CreationResult.PrimaryOutputs.Count, result.CreationResult.PrimaryOutputs.Count); Assert.Equal( expectedResult.CreationResult.PrimaryOutputs.Select(po => po.Path).OrderBy(s => s, StringComparer.OrdinalIgnoreCase), result.CreationResult.PrimaryOutputs.Select(po => po.Path).OrderBy(s => s, StringComparer.OrdinalIgnoreCase), StringComparer.OrdinalIgnoreCase); IFileChangeComparer comparer = new IFileChangeComparer(); Assert.Equal(expectedResult.FileChanges.Count, result.FileChanges.Count); Assert.Equal( expectedResult.FileChanges.OrderBy(s => s, comparer), result.FileChanges.OrderBy(s => s, comparer), comparer); }
internal async Task CanUninstall_Folder() { using Bootstrapper bootstrapper = BootstrapperFactory.GetBootstrapper(); string templateLocation = TestUtils.GetTestTemplateLocation("TemplateWithSourceName"); InstallRequest installRequest = new InstallRequest(Path.GetFullPath(templateLocation)); IReadOnlyList <InstallResult> result = await bootstrapper.InstallTemplatePackagesAsync(new[] { installRequest }, InstallationScope.Global, CancellationToken.None).ConfigureAwait(false); Assert.Equal(1, result.Count); Assert.True(result[0].Success); IManagedTemplatePackage source = result[0].TemplatePackage; Assert.Equal(templateLocation, source.MountPointUri); IReadOnlyList <IManagedTemplatePackage> managedTemplatesPackages = await bootstrapper.GetManagedTemplatePackages(CancellationToken.None).ConfigureAwait(false); Assert.Equal(1, managedTemplatesPackages.Count); managedTemplatesPackages[0].Should().BeEquivalentTo(source); IReadOnlyList <UninstallResult> uninstallResults = await bootstrapper.UninstallTemplatePackagesAsync(new[] { source }, CancellationToken.None).ConfigureAwait(false); Assert.Equal(1, uninstallResults.Count); Assert.True(uninstallResults[0].Success); Assert.Equal(InstallerErrorCode.Success, uninstallResults[0].Error); uninstallResults[0].ErrorMessage.Should().BeNullOrEmpty(); Assert.Equal(source, uninstallResults[0].TemplatePackage); IReadOnlyList <ITemplatePackage> templatePackages = await bootstrapper.GetTemplatePackages(CancellationToken.None).ConfigureAwait(false); Assert.Equal(0, templatePackages.Count); Directory.Exists(templateLocation); }
internal async Task CanReInstallFolder_WhenForceIsSpecified() { using Bootstrapper bootstrapper = BootstrapperFactory.GetBootstrapper(); string templateLocation = TestUtils.GetTestTemplateLocation("TemplateWithSourceName"); InstallRequest installRequest = new InstallRequest(Path.GetFullPath(templateLocation)); IReadOnlyList <InstallResult> result = await bootstrapper.InstallTemplatePackagesAsync(new[] { installRequest }, InstallationScope.Global, CancellationToken.None).ConfigureAwait(false); Assert.Equal(1, result.Count); Assert.True(result[0].Success); Assert.Equal(InstallerErrorCode.Success, result[0].Error); result[0].ErrorMessage.Should().BeNullOrEmpty(); Assert.Equal(installRequest, result[0].InstallRequest); InstallRequest repeatedInstallRequest = new InstallRequest(Path.GetFullPath(templateLocation), force: true); result = await bootstrapper.InstallTemplatePackagesAsync(new[] { repeatedInstallRequest }, InstallationScope.Global, CancellationToken.None).ConfigureAwait(false); Assert.Equal(1, result.Count); Assert.True(result[0].Success); Assert.Equal(InstallerErrorCode.Success, result[0].Error); result[0].ErrorMessage.Should().BeNullOrEmpty(); Assert.Equal(repeatedInstallRequest, result[0].InstallRequest); InstallRequest repeatedInstallRequestWithoutForce = new InstallRequest(Path.GetFullPath(templateLocation)); result = await bootstrapper.InstallTemplatePackagesAsync(new[] { repeatedInstallRequestWithoutForce }, InstallationScope.Global, CancellationToken.None).ConfigureAwait(false); Assert.Equal(1, result.Count); Assert.False(result[0].Success); Assert.Equal(InstallerErrorCode.AlreadyInstalled, result[0].Error); }
internal async Task CanReInstallRemotePackage_WhenForceIsSpecified() { using Bootstrapper bootstrapper = BootstrapperFactory.GetBootstrapper(); InstallRequest installRequest = new InstallRequest("Microsoft.DotNet.Common.ProjectTemplates.5.0", version: "5.0.0"); IReadOnlyList <InstallResult> result = await bootstrapper.InstallTemplatePackagesAsync(new[] { installRequest }, InstallationScope.Global, CancellationToken.None).ConfigureAwait(false); Assert.Equal(1, result.Count); Assert.True(result[0].Success); Assert.Equal(InstallerErrorCode.Success, result[0].Error); Assert.True(string.IsNullOrEmpty(result[0].ErrorMessage)); Assert.Equal(installRequest, result[0].InstallRequest); InstallRequest repeatedInstallRequest = new InstallRequest("Microsoft.DotNet.Common.ProjectTemplates.5.0", version: "5.0.0", force: true); result = await bootstrapper.InstallTemplatePackagesAsync(new[] { repeatedInstallRequest }, InstallationScope.Global, CancellationToken.None).ConfigureAwait(false); Assert.Equal(1, result.Count); Assert.True(result[0].Success); Assert.Equal(InstallerErrorCode.Success, result[0].Error); result[0].ErrorMessage.Should().BeNullOrEmpty(); Assert.Equal(repeatedInstallRequest, result[0].InstallRequest); InstallRequest repeatedInstallRequestWithoutForce = new InstallRequest("Microsoft.DotNet.Common.ProjectTemplates.5.0", version: "5.0.0"); result = await bootstrapper.InstallTemplatePackagesAsync(new[] { repeatedInstallRequestWithoutForce }, InstallationScope.Global, CancellationToken.None).ConfigureAwait(false); Assert.Equal(1, result.Count); Assert.False(result[0].Success); Assert.Equal(InstallerErrorCode.AlreadyInstalled, result[0].Error); }
internal async Task CanInstall_LocalNuGetPackage() { using Bootstrapper bootstrapper = BootstrapperFactory.GetBootstrapper(); string packageLocation = await _packageManager.GetNuGetPackage("Microsoft.DotNet.Common.ProjectTemplates.5.0").ConfigureAwait(false); InstallRequest installRequest = new InstallRequest(Path.GetFullPath(packageLocation)); IReadOnlyList <InstallResult> result = await bootstrapper.InstallTemplatePackagesAsync(new[] { installRequest }, InstallationScope.Global, CancellationToken.None).ConfigureAwait(false); Assert.Equal(1, result.Count); Assert.True(result[0].Success); Assert.Equal(InstallerErrorCode.Success, result[0].Error); result[0].ErrorMessage.Should().BeNullOrEmpty(); Assert.Equal(installRequest, result[0].InstallRequest); IManagedTemplatePackage source = result[0].TemplatePackage; Assert.Equal("Microsoft.DotNet.Common.ProjectTemplates.5.0", source.Identifier); Assert.Equal("Global Settings", source.Provider.Factory.DisplayName); Assert.Equal("NuGet", source.Installer.Factory.Name); Assert.Equal("Microsoft", source.GetDetails()["Author"]); source.Version.Should().NotBeNullOrEmpty(); IReadOnlyList <IManagedTemplatePackage> managedTemplatesPackages = await bootstrapper.GetManagedTemplatePackages(CancellationToken.None).ConfigureAwait(false); Assert.Equal(1, managedTemplatesPackages.Count); managedTemplatesPackages[0].Should().BeEquivalentTo(source); IReadOnlyList <ITemplatePackage> templatePackages = await bootstrapper.GetTemplatePackages(CancellationToken.None).ConfigureAwait(false); Assert.Equal(1, templatePackages.Count); Assert.IsAssignableFrom <IManagedTemplatePackage>(templatePackages[0]); templatePackages[0].Should().BeEquivalentTo((ITemplatePackage)source); }
internal async Task GetCreationEffects_BasicTest_Folder() { using Bootstrapper bootstrapper = BootstrapperFactory.GetBootstrapper(); await bootstrapper.InstallTestTemplateAsync("TemplateWithSourceName").ConfigureAwait(false); string output = TestUtils.CreateTemporaryFolder(); var foundTemplates = await bootstrapper.GetTemplatesAsync( new[] { WellKnownSearchFilters.NameFilter("TestAssets.TemplateWithSourceName") }).ConfigureAwait(false); var result = await bootstrapper.GetCreationEffectsAsync(foundTemplates[0].Info, "test", output, new Dictionary <string, string>(), "").ConfigureAwait(false); Assert.Equal(2, result.CreationResult.PrimaryOutputs.Count); Assert.Equal(0, result.CreationResult.PostActions.Count); Assert.Equal(2, result.FileChanges.Count); var expectedFileChanges = new FileChange[] { new FileChange("bar.cs", "test.cs", ChangeKind.Create), new FileChange("bar/bar.cs", "test/test.cs", ChangeKind.Create), }; IFileChangeComparer comparer = new IFileChangeComparer(); Assert.Equal( expectedFileChanges.OrderBy(s => s, comparer), result.FileChanges.OrderBy(s => s, comparer), comparer); }
public static Bootstrapper CreateWeb(this BootstrapperFactory factory, string[] args) => factory .CreateDefault(args) .AddPipelines(typeof(BootstrapperFactoryExtensions).Assembly) .AddSettingsIfNonExisting(new Dictionary <string, object> { { WebKeys.MirrorResources, true } });
public void TestNewSpringRunner() { Runner runner = BootstrapperFactory.NewSpringRunner(LoggerSetter, SpringBootstrapper); Assert.IsNotNull(runner); Assert.IsInstanceOf(typeof(SpringRunnerImpl), runner); Assert.IsTrue(LoggerSetterImpl.LoggerRecipients.Contains(runner)); }
public void TestNewLogBootstrapper() { LogBootstrapper logBootstrapper = BootstrapperFactory.NewLogBootstrapper(); Assert.IsNotNull(logBootstrapper); Assert.IsInstanceOf(typeof(Bootstrapper), logBootstrapper); Assert.IsInstanceOf(typeof(LogBootstrapperImpl), logBootstrapper); }
private void App_OnStartup(object sender, StartupEventArgs e) { var bootstrapp = BootstrapperFactory.Create(AvailablePatterns.Mvvm, Namespace.FromCurrentCaller()); var mainView = bootstrapp.Boot <IMainView>(); mainView.Display(); }
public void TestBootstrap() { AssemblyResolver bootstrapper = BootstrapperFactory.NewAssemblyResolver(LoggerSetter); LoggerSetter.SetLoggers(); Assert.IsFalse(bootstrapper.IsDone); bootstrapper.Bootstrap(); Assert.IsTrue(bootstrapper.IsDone); }
private void HandleApplicationStartup(object sender, StartupEventArgs e) { var bootstrapper = BootstrapperFactory.Create(BootstrapperType.OrderSystem); if (bootstrapper != default(Bootstrapper)) { bootstrapper.Run(); } }
public void TestNewAssemblyResolver() { AssemblyResolver assemblyResolver = BootstrapperFactory.NewAssemblyResolver(LoggerSetter); Assert.IsNotNull(assemblyResolver); Assert.IsInstanceOf(typeof(Bootstrapper), assemblyResolver); Assert.IsInstanceOf(typeof(AssemblyResolverImpl), assemblyResolver); Assert.IsTrue(LoggerSetterImpl.LoggerRecipients.Contains(assemblyResolver)); }
public void TestRun() { Runner runner = BootstrapperFactory.NewSpringRunner(LoggerSetter, SpringBootstrapper); Bootstrapper.Bootstrap(); Assert.IsFalse(runner.IsDone); runner.Run(); Assert.IsTrue(runner.IsDone); }
public void TestBootstrap() { SpringBootstrapper bootstrapper = BootstrapperFactory.NewSpringBootstrapper(LoggerSetter); LoggerSetter.Bootstrap(); Assert.IsFalse(bootstrapper.IsDone); bootstrapper.Bootstrap(); Assert.IsTrue(bootstrapper.IsDone); Assert.IsNotNull(bootstrapper.Ctx); }
public void Create_BootstrapperFactory() { //arrange var bootstrapperFactory = new BootstrapperFactory(new Mock <ILogger <Bootstrapper> >().Object); //act var bootstrapper = bootstrapperFactory.Create(TimeSpan.FromMinutes(1)); //assert Assert.NotNull(bootstrapper); }
public void TestNewCompositeBootstrapper() { CompositeBootstrapper compositeBootstrapper = BootstrapperFactory.NewCompositeBootstrapper(LoggerSetter, Bootstrappers); Assert.IsNotNull(compositeBootstrapper); Assert.IsInstanceOf(typeof(Bootstrapper), compositeBootstrapper); Assert.IsInstanceOf(typeof(CompositeBootstrapperImpl), compositeBootstrapper); CompositeBootstrapperImpl compositeBootstrapperImpl = (CompositeBootstrapperImpl)compositeBootstrapper; Assert.AreEqual(Bootstrappers, compositeBootstrapperImpl.SubBootstrappers); Assert.IsTrue(LoggerSetterImpl.LoggerRecipients.Contains(compositeBootstrapper)); }
internal async Task CreateBasicTest() { var bootstrapper = BootstrapperFactory.GetBootstrapper(additionalVirtualLocations: new string[] { "test" }); bootstrapper.InstallTestTemplate("TemplateWithSourceName"); var template = bootstrapper.ListTemplates(true, WellKnownSearchFilters.NameFilter("TestAssets.TemplateWithSourceName")); var result = await bootstrapper.CreateAsync(template.First().Info, "test", "test", new Dictionary <string, string>(), false, "").ConfigureAwait(false); Assert.Equal(2, result.PrimaryOutputs.Count); Assert.Equal(0, result.PostActions.Count); }
public static IHostBuilder UseBootstrapperFactory(this IHostBuilder builder, IAssemblyCatalog assemblyCatalog, BootstrapperOptions options, IEnumerable <ModuleMetadataValidator> validators = null) { return(builder.UseServiceProviderFactory(context => { var moduleLoader = new ModuleLoader(validators); options.ConfigureBuildTimeServices.Add(collection => collection.AddSingleton(context.HostingEnvironment)); options.ConfigureBuildTimeServices.Add(collection => collection.AddSingleton(context.Configuration)); return BootstrapperFactory.Create(moduleLoader, assemblyCatalog, options); })); }
/// <summary> /// Adds Simplify.Web to OWIN pipeline /// </summary> /// <param name="builder">The OWIN builder.</param> /// <returns></returns> public static IAppBuilder UseSimplifyWeb(this IAppBuilder builder) { try { BootstrapperFactory.CreateBootstrapper().Register(); return(builder.Use <SimplifyWebOwinMiddleware>()); } catch (Exception e) { SimplifyWebOwinMiddleware.ProcessOnException(e); throw; } }
public void CreateBootstrapper_HaveUserType_TestBootstrapperReturned() { // Assign SimplifyWebTypesFinder.ExcludedAssembliesPrefixes.Remove("Simplify"); SimplifyWebTypesFinder.CleanLoadedTypesAndAssembliesInfo(); // Act var bootstrapper = BootstrapperFactory.CreateBootstrapper(); // Assert Assert.AreEqual("Simplify.Web.Tests.TestEntities.TestBootstrapper", bootstrapper.GetType().FullName); }
internal async Task Create_BasicTest_Folder() { using Bootstrapper bootstrapper = BootstrapperFactory.GetBootstrapper(additionalVirtualLocations: new string[] { "test" }); await bootstrapper.InstallTestTemplateAsync("TemplateWithSourceName").ConfigureAwait(false); string output = TestUtils.CreateTemporaryFolder(); var foundTemplates = await bootstrapper.GetTemplatesAsync( new[] { WellKnownSearchFilters.NameFilter("TestAssets.TemplateWithSourceName") }).ConfigureAwait(false); var result = await bootstrapper.CreateAsync(foundTemplates[0].Info, "test", output, new Dictionary <string, string>(), false, "").ConfigureAwait(false); Assert.Equal(2, result.PrimaryOutputs.Count); Assert.Equal(0, result.PostActions.Count); Assert.True(File.Exists(Path.Combine(output, "test.cs"))); Assert.True(File.Exists(Path.Combine(output, "test/test.cs"))); }