Esempio n. 1
0
        private ProcessorInfo GetProcessorInfo(IDocumentProcessor processor, string versionName)
        {
            var cpi = new ProcessorInfo
            {
                Name = processor.Name,
                IncrementalContextHash = ((ISupportIncrementalBuild)processor).GetIncrementalContextHash(),
            };

            foreach (var step in processor.BuildSteps)
            {
                cpi.Steps.Add(new ProcessorStepInfo
                {
                    Name = step.Name,
                    IncrementalContextHash = ((ISupportIncrementalBuild)step).GetIncrementalContextHash(),
                });
            }
            var cvi = CurrentBuildInfo.Versions.Find(v => v.VersionName == versionName);

            if (cvi == null)
            {
                cvi = new BuildVersionInfo {
                    VersionName = versionName
                };
                CurrentBuildInfo.Versions.Add(cvi);
            }
            cvi.Processors.Add(cpi);
            return(cpi);
        }
Esempio n. 2
0
        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(),
            });
        }