private IEnumerable <HostService> GetInnerContexts( DocumentBuildParameters parameters, IEnumerable <IDocumentProcessor> processors, TemplateProcessor templateProcessor, IMarkdownService markdownService) { var k = from fileItem in ( from file in parameters.Files.EnumerateFiles() from p in (from processor in processors let priority = processor.GetProcessingPriority(file) where priority != ProcessingPriority.NotSupported group processor by priority into ps orderby ps.Key descending select ps.ToList()).FirstOrDefault() ?? new List <IDocumentProcessor> { null } select new { file, p }) group fileItem by fileItem.p; var toHandleItems = k.Where(s => s.Key != null); var notToHandleItems = k.Where(s => s.Key == null); foreach (var item in notToHandleItems) { var sb = new StringBuilder(); sb.AppendLine("Cannot handle following file:"); foreach (var f in item) { sb.Append("\t"); sb.AppendLine(f.file.File); } Logger.LogWarning(sb.ToString()); } // todo : revert until PreProcessor ready return(from processor in processors join item in toHandleItems on processor equals item.Key into g from item in g.DefaultIfEmpty().AsParallel().WithDegreeOfParallelism(parameters.MaxParallelism) select new HostService( parameters.Files.DefaultBaseDir, item == null ? new FileModel[0] : from file in item select Load(processor, parameters.Metadata, parameters.FileMetadata, file.file) into model where model != null select model) { MarkdownService = markdownService, Processor = processor, Template = templateProcessor, Validators = MetadataValidators.ToImmutableList(), }); }
private IEnumerable <HostService> GetInnerContexts( DocumentBuildParameters parameters, IEnumerable <IDocumentProcessor> processors, TemplateProcessor templateProcessor, IMarkdownService markdownService, DocumentBuildContext context) { var k = from fileItem in ( from file in parameters.Files.EnumerateFiles() from p in (from processor in processors let priority = processor.GetProcessingPriority(file) where priority != ProcessingPriority.NotSupported group processor by priority into ps orderby ps.Key descending select ps.ToList()).FirstOrDefault() ?? new List <IDocumentProcessor> { null } select new { file, p }) group fileItem by fileItem.p; var toHandleItems = k.Where(s => s.Key != null); var notToHandleItems = k.Where(s => s.Key == null); foreach (var item in notToHandleItems) { var sb = new StringBuilder(); sb.AppendLine("Cannot handle following file:"); foreach (var f in item) { sb.Append("\t"); sb.AppendLine(f.file.File); } Logger.LogWarning(sb.ToString()); } // todo : revert until PreProcessor ready foreach (var pair in (from processor in processors join item in toHandleItems on processor equals item.Key into g from item in g.DefaultIfEmpty() select new { processor, item, }).AsParallel().WithDegreeOfParallelism(parameters.MaxParallelism)) { var incrementalContext = context.IncrementalBuildContext; var processorSupportIncremental = IsProcessorSupportIncremental(pair.processor); bool processorCanIncremental = processorSupportIncremental; if (processorSupportIncremental) { incrementalContext.CreateProcessorInfo(pair.processor); processorCanIncremental = incrementalContext.CanProcessorIncremental(pair.processor); } var hostService = new HostService( parameters.Files.DefaultBaseDir, pair.item == null ? new FileModel[0] : from file in pair.item select Load(pair.processor, parameters.Metadata, parameters.FileMetadata, file.file, processorCanIncremental, context) into model where model != null select model) { MarkdownService = markdownService, Processor = pair.processor, Template = templateProcessor, Validators = MetadataValidators.ToImmutableList(), ShouldTraceIncrementalInfo = processorSupportIncremental, CanIncrementalBuild = processorCanIncremental, }; if (ShouldTraceIncrementalInfo) { using (new LoggerPhaseScope("ReportModelLoadInfo", true)) { var allFiles = pair.item?.Select(f => f.file.File) ?? new string[0]; var loadedFiles = hostService.Models.Select(m => m.FileAndType.File); incrementalContext.ReportModelLoadInfo(hostService, allFiles.Except(loadedFiles), null); incrementalContext.ReportModelLoadInfo(hostService, loadedFiles, BuildPhase.PreBuild); } } yield return(hostService); } }
private IEnumerable <HostService> GetInnerContexts( DocumentBuildParameters parameters, IEnumerable <IDocumentProcessor> processors, TemplateProcessor templateProcessor, IMarkdownService markdownService, DocumentBuildContext context) { var k = from fileItem in ( from file in parameters.Files.EnumerateFiles() from p in (from processor in processors let priority = processor.GetProcessingPriority(file) where priority != ProcessingPriority.NotSupported group processor by priority into ps orderby ps.Key descending select ps.ToList()).FirstOrDefault() ?? new List <IDocumentProcessor> { null } select new { file, p }) group fileItem by fileItem.p; var toHandleItems = k.Where(s => s.Key != null); var notToHandleItems = k.Where(s => s.Key == null); foreach (var item in notToHandleItems) { var sb = new StringBuilder(); sb.AppendLine("Cannot handle following file:"); foreach (var f in item) { sb.Append("\t"); sb.AppendLine(f.file.File); } Logger.LogWarning(sb.ToString()); } // todo : revert until PreProcessor ready var pairs = from processor in processors join item in toHandleItems on processor equals item.Key into g from item in g.DefaultIfEmpty() select new { processor, item, canProcessorIncremental = CanProcessorIncremental(processor, parameters.VersionName), }; // load last xrefspecmap and manifestitems BuildVersionInfo lbvi = LastBuildInfo?.Versions.SingleOrDefault(v => v.VersionName == parameters.VersionName); var lastXRefSpecMap = lbvi?.XRefSpecMap; var lastManifest = lbvi?.Manifest; var lastDependencyGraph = lbvi?.Dependency; return(from pair in pairs.AsParallel().WithDegreeOfParallelism(parameters.MaxParallelism) select new HostService( parameters.Files.DefaultBaseDir, pair.item == null ? new FileModel[0] : from file in pair.item select Load(pair.processor, parameters.Metadata, parameters.FileMetadata, file.file, pair.canProcessorIncremental, lastXRefSpecMap, lastManifest, lastDependencyGraph, context) into model where model != null select model) { MarkdownService = markdownService, Processor = pair.processor, Template = templateProcessor, Validators = MetadataValidators.ToImmutableList(), }); }