private async Task <IEnumerable <ImportingJobDescriptor> > HarvestManifestAsync(IFeatureInfo feature, string path) { var manifestPath = Path.Combine("Areas", feature.Id, path); var manifestFile = _environment.ContentRootFileProvider.GetFileInfo(manifestPath); if (manifestFile == null || manifestFile is NotFoundFileInfo) { return(new ImportingJobDescriptor[] { }); } using (var stream = manifestFile.CreateReadStream()) { var manifest = await _xaml.LoadAsync <SeedManifest>(stream); var dataSources = manifest.DataSources; var jobs = new List <ImportingJobDescriptor>(); foreach (var ds in dataSources) { foreach (var importEntity in ds.Mappings) { var job = new ImportingJobDescriptor( true, feature, ds, importEntity); jobs.Add(job); } } return(jobs); } }
public static Task <T> LoadFromEmbeddedResourceAsync <T>(this IXamlService self, Assembly assembly, string path) { using (var stream = assembly.GetManifestResourceStream(path)) { if (stream == null) { throw new FileNotFoundException(); } return(self.LoadAsync <T>(stream)); } }
public async Task <IEnumerable <IViewDefinition> > HarvestAsync(IFeatureInfo feature) { var featureStartup = await _s2StartupService.GetOrDefaultByFeatureAsync(feature); if (featureStartup == null) { return(new IViewDefinition[] { }); } var viewFiles = new ViewDefinitionsCollection(); featureStartup.ConfigureViews(viewFiles); var defs = new List <IViewDefinition>(); foreach (var vf in viewFiles) { //读取文件 var viewFilePath = Path.Combine("Areas", feature.Id, vf.Path); var viewFileInfo = _environment.ContentRootFileProvider.GetFileInfo(viewFilePath); if (!viewFileInfo.Exists) { throw new FileNotFoundException($"File not found: '{viewFilePath}'", viewFilePath); } this.Logger.LogInformation($"View definition file found: {viewFilePath}"); using (var vfs = viewFileInfo.CreateReadStream()) { var viewDefinitions = await _xaml.LoadAsync <S2ViewDefinitions>(vfs); foreach (var vd in viewDefinitions.Definitions) { if (string.IsNullOrEmpty(vd.Feature)) { vd.Feature = feature.Id; } } defs.AddRange(viewDefinitions.Definitions); } } return(defs); }
public static Task <T> LoadFromFileAsync <T>(this IXamlService self, string filePath) { using (var stream = File.OpenRead(filePath)) { return(self.LoadAsync <T>(stream)); } }
public static Task <T> LoadFromStringAsync <T>(this IXamlService self, string xmlStr) { return(self.LoadAsync <T>(new StringReader(xmlStr))); }