/// <summary> /// Returns a list of recipes for a content path. /// </summary> /// <param name="path">A path string relative to the content root of the application.</param> /// <returns>The list of <see cref="RecipeDescriptor"/> instances.</returns> protected Task <IEnumerable <RecipeDescriptor> > HarvestRecipesAsync(string path) { var recipeDescriptors = new List <RecipeDescriptor>(); var recipeFiles = _hostingEnvironment.ContentRootFileProvider.GetDirectoryContents(path) .Where(x => !x.IsDirectory && x.Name.EndsWith(".recipe.json")); recipeDescriptors.AddRange(recipeFiles.Select(recipeFile => _recipeReader.GetRecipeDescriptor(path, recipeFile, _hostingEnvironment.ContentRootFileProvider).Result)); return(Task.FromResult <IEnumerable <RecipeDescriptor> >(recipeDescriptors)); }
public async Task <string> ExecuteAsync(string recipeFileName, IDataMigration migration) { var featureInfo = _typeFeatureProvider.GetFeatureForDependency(migration.GetType()); var recipeBasePath = Path.Combine(featureInfo.Extension.SubPath, "Migrations").Replace('\\', '/'); var recipeFilePath = Path.Combine(recipeBasePath, recipeFileName).Replace('\\', '/'); var recipeFileInfo = _hostingEnvironment.ContentRootFileProvider.GetFileInfo(recipeFilePath); var recipeDescriptor = await _recipeReader.GetRecipeDescriptor(recipeBasePath, recipeFileInfo, _hostingEnvironment.ContentRootFileProvider); recipeDescriptor.RequireNewScope = false; var executionId = Guid.NewGuid().ToString("n"); return(await _recipeExecutor.ExecuteAsync(executionId, recipeDescriptor, new object(), CancellationToken.None)); }
public async Task <string> ExecuteAsync(string recipeFileName, IDataMigration migration) { var featureInfo = _typeFeatureProvider.GetFeatureForDependency(migration.GetType()); var recipeBasePath = Path.Combine(featureInfo.Extension.SubPath, "Migrations").Replace('\\', '/'); var recipeFilePath = Path.Combine(recipeBasePath, recipeFileName).Replace('\\', '/'); var recipeFileInfo = _hostingEnvironment.ContentRootFileProvider.GetFileInfo(recipeFilePath); var recipeDescriptor = await _recipeReader.GetRecipeDescriptor(recipeBasePath, recipeFileInfo, _hostingEnvironment.ContentRootFileProvider); recipeDescriptor.RequireNewScope = false; var environment = new Dictionary <string, object>(); await _environmentProviders.OrderBy(x => x.Order).InvokeAsync((provider, env) => provider.PopulateEnvironmentAsync(env), environment, _logger); var executionId = Guid.NewGuid().ToString("n"); return(await _recipeExecutor.ExecuteAsync(executionId, recipeDescriptor, environment, CancellationToken.None)); }
private async Task <IEnumerable <RecipeDescriptor> > HarvestRecipesAsync(string[] paths) { var recipeDescriptors = new List <RecipeDescriptor>(); var testAssemblyFileProvider = new EmbeddedFileProvider(GetType().GetTypeInfo().Assembly); var fileInfos = new List <IFileInfo>(); foreach (var path in paths) { // EmbeddedFileProvider doesn't list directory contents. var fileInfo = testAssemblyFileProvider.GetFileInfo(path); Assert.True(fileInfo.Exists); fileInfos.Add(fileInfo); } foreach (var fileInfo in fileInfos) { var descriptor = await _recipeReader.GetRecipeDescriptor(fileInfo.PhysicalPath, fileInfo, testAssemblyFileProvider); recipeDescriptors.Add(descriptor); } return(recipeDescriptors); }