Exemple #1
0
 private void ReportDependencyCore(DependencyItemSourceInfo from, DependencyItemSourceInfo to, DependencyItemSourceInfo reportedBy, string type)
 {
     DependencyGraph.ReportDependency(new DependencyItem(from, to, reportedBy, type));
 }
Exemple #2
0
 private void ReportDependencyCore(string from, string to, string reportedBy, string type)
 {
     DependencyGraph.ReportDependency(new DependencyItem(from, to, reportedBy, type));
 }
Exemple #3
0
        private static FileModel Load(
            IDocumentProcessor processor,
            ImmutableDictionary <string, object> metadata,
            FileMetadata fileMetadata,
            FileAndType file,
            bool canProcessorIncremental,
            IDictionary <string, XRefSpec> xrefSpecMap,
            IEnumerable <ManifestItem> manifestItems,
            DependencyGraph dg,
            DocumentBuildContext context)
        {
            using (new LoggerFileScope(file.File))
            {
                Logger.LogDiagnostic($"Processor {processor.Name}, File {file.FullPath}: Loading...");

                if (canProcessorIncremental)
                {
                    ChangeKindWithDependency ck;
                    string fileKey = ((RelativePath)file.File).GetPathFromWorkingFolder().ToString();
                    if (context.ChangeDict.TryGetValue(fileKey, out ck))
                    {
                        if (ck == ChangeKindWithDependency.Deleted)
                        {
                            return(null);
                        }
                        if (ck == ChangeKindWithDependency.None)
                        {
                            Logger.LogDiagnostic($"Processor {processor.Name}, File {file.FullPath}: Check incremental...");
                            if (((ISupportIncrementalBuild)processor).CanIncrementalBuild(file) &&
                                processor.BuildSteps.Cast <ISupportIncrementalBuild>().All(step => step.CanIncrementalBuild(file)))
                            {
                                Logger.LogDiagnostic($"Processor {processor.Name}, File {file.FullPath}: Skip build by incremental.");

                                // restore filemap
                                context.FileMap[fileKey] = ((RelativePath)file.File).GetPathFromWorkingFolder();

                                // restore xrefspec
                                var specs = xrefSpecMap?.Values?.Where(spec => spec.Href == fileKey);
                                if (specs != null)
                                {
                                    foreach (var spec in specs)
                                    {
                                        context.XRefSpecMap[spec.Uid] = spec;
                                    }
                                }

                                // restore manifestitem
                                ManifestItem item = manifestItems?.SingleOrDefault(i => i.SourceRelativePath == file.File);
                                if (item != null)
                                {
                                    context.ManifestItems.Add(item);
                                }

                                // restore dependency graph
                                if (dg.HasDependency(fileKey))
                                {
                                    context.DependencyGraph.ReportDependency(fileKey, dg.GetDirectDependency(fileKey));
                                }
                                return(null);
                            }
                            Logger.LogDiagnostic($"Processor {processor.Name}, File {file.FullPath}: Incremental not available.");
                        }
                    }
                }

                var path = Path.Combine(file.BaseDir, file.File);
                metadata = ApplyFileMetadata(path, metadata, fileMetadata);
                try
                {
                    return(processor.Load(file, metadata));
                }
                catch (Exception)
                {
                    Logger.LogError($"Unable to load file: {file.File} via processor: {processor.Name}.");
                    throw;
                }
            }
        }