Example #1
0
        private static Dictionary<string, FileAttributeItem> ComputeFileAttributes(DocumentBuildParameters parameters, DependencyGraph dg)
        {
            var filesInScope = from f in parameters.Files.EnumerateFiles()
                               let fileKey = ((RelativePath)f.File).GetPathFromWorkingFolder().ToString()
                               select new
                               {
                                   PathFromWorkingFolder = fileKey,
                                   FullPath = f.FullPath
                               };
            var files = filesInScope;
            if (dg != null)
            {
                var filesFromDependency = from node in dg.GetAllDependentNodes()
                                          let fullPath = Path.Combine(EnvironmentContext.BaseDirectory, ((RelativePath)node).RemoveWorkingFolder())
                                          select new
                                          {
                                              PathFromWorkingFolder = node,
                                              FullPath = fullPath
                                          };
                files = files.Concat(filesFromDependency);
            }


            return (from item in files
                    where File.Exists(item.FullPath)
                    group item by item.PathFromWorkingFolder into g
                    select new FileAttributeItem
                    {
                        File = g.Key,
                        LastModifiedTime = File.GetLastWriteTimeUtc(g.First().FullPath),
                        MD5 = StringExtension.GetMd5String(File.ReadAllText(g.First().FullPath)),
                    }).ToDictionary(a => a.File);
        }
Example #2
0
        private static DependencyGraph ConstructDependencyGraphFromLast(DependencyGraph ldg)
        {
            var dg = new DependencyGraph();
            if (ldg == null)
            {
                return dg;
            }

            // reregister dependency types from last dependency graph
            using (new LoggerPhaseScope("RegisterDependencyTypeFromLastBuild", true))
            {
                dg.RegisterDependencyType(ldg.DependencyTypes.Values);
            }

            // restore dependency graph from last dependency graph
            using (new LoggerPhaseScope("ReportDependencyFromLastBuild", true))
            {
                dg.ReportDependency(from r in ldg.ReportedBys
                                    from i in ldg.GetDependencyReportedBy(r)
                                    select i);
            }
            return dg;
        }
Example #3
0
        public List<string> ExpandDependency(DependencyGraph dependencyGraph, Func<DependencyItem, bool> isValid)
        {
            var newChanges = new List<string>();

            if (dependencyGraph != null)
            {
                foreach (var from in dependencyGraph.FromNodes)
                {
                    if (dependencyGraph.GetAllDependencyFrom(from).Any(d => isValid(d) && _changeDict.ContainsKey(d.To) && _changeDict[d.To] != ChangeKindWithDependency.None))
                    {
                        if (!_changeDict.ContainsKey(from))
                        {
                            _changeDict[from] = ChangeKindWithDependency.DependencyUpdated;
                            newChanges.Add(from);
                        }
                        else
                        {
                            if (_changeDict[from] == ChangeKindWithDependency.None)
                            {
                                newChanges.Add(from);
                            }
                            _changeDict[from] |= ChangeKindWithDependency.DependencyUpdated;
                        }
                    }
                }
            }
            return newChanges;
        }
Example #4
0
        private static Dictionary <string, FileAttributeItem> ComputeFileAttributes(DocumentBuildParameters parameters, DependencyGraph dg)
        {
            var filesInScope = from f in parameters.Files.EnumerateFiles()
                               let fileKey = ((RelativePath)f.File).GetPathFromWorkingFolder().ToString()
                                             select new
            {
                PathFromWorkingFolder = fileKey,
                FullPath = f.FullPath
            };
            var files = filesInScope;

            if (dg != null)
            {
                var filesFromDependency = from node in dg.GetAllDependentNodes()
                                          let p = RelativePath.TryParse(node)
                                                  where p != null
                                                  let fullPath = Path.Combine(EnvironmentContext.BaseDirectory, p.RemoveWorkingFolder())
                                                                 select new
                {
                    PathFromWorkingFolder = node,
                    FullPath = fullPath
                };
                files = files.Concat(filesFromDependency);
            }


            return((from item in files
                    where File.Exists(item.FullPath)
                    group item by item.PathFromWorkingFolder into g
                    select new FileAttributeItem
            {
                File = g.Key,
                LastModifiedTime = File.GetLastWriteTimeUtc(g.First().FullPath),
                MD5 = StringExtension.GetMd5String(File.ReadAllText(g.First().FullPath)),
            }).ToDictionary(a => a.File));
        }