Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

refactor

  • Loading branch information...
commit f3fc0276ef1504a4718561734e1b9686f96d4758 1 parent 8bbef56
Lucas Meijer authored
View
12 DependencyGraph.cs
@@ -15,14 +15,14 @@ public void RequestTarget(string targetFile)
{
var instructions = _graph[targetFile];
- if (instructions.SourceFiles.Any(sourceFile => !File.Exists(sourceFile)))
+ if (instructions.Settings.InputFiles.Any(inputFile => !File.Exists(inputFile)))
throw new MissingDependencyException();
- if (NeedToGenerate(targetFile, instructions))
+ if (NeedToGenerate(targetFile, instructions.Settings))
Generate(targetFile, instructions);
}
- private bool NeedToGenerate(string targetFile, TargetBuildInstructions instructions)
+ private bool NeedToGenerate(string targetFile, TargetBuildSettings buildSettings)
{
var recordOfLastBuild = _buildHistory.FindRecordFor(targetFile);
@@ -35,15 +35,15 @@ private bool NeedToGenerate(string targetFile, TargetBuildInstructions instructi
if (File.GetLastWriteTimeUtc(targetFile) < recordOfLastBuild.ModificationTimeOfTargetFile())
return true;
- return instructions.SourceFiles.Any(sourceFile => recordOfLastBuild.ModificationTimeOf(sourceFile) != File.GetLastWriteTimeUtc(sourceFile));
+ return buildSettings.InputFiles.Any(sourceFile => recordOfLastBuild.ModificationTimeOf(sourceFile) != File.GetLastWriteTimeUtc(sourceFile));
}
private void Generate(string targetFile, TargetBuildInstructions instructions)
{
GenerateCallback(targetFile, instructions);
- instructions.Action(targetFile, instructions.SourceFiles);
+ instructions.Action(targetFile, instructions.Settings);
- var record = new GenerationRecord(targetFile, instructions.SourceFiles);
+ var record = new GenerationRecord(targetFile, instructions.Settings);
_buildHistory.AddRecord(record);
}
View
10 GenerationRecord.cs
@@ -7,18 +7,18 @@ namespace bs
internal class GenerationRecord
{
public string TargetFile { get; private set; }
- public IEnumerable<string> SourceFiles { get; private set; }
+ public TargetBuildSettings Settings { get; private set; }
private readonly Dictionary<string, DateTime> _modificationDates = new Dictionary<string, DateTime>();
- public GenerationRecord(string targetFile, IEnumerable<string> sourceFiles)
+ public GenerationRecord(string targetFile, TargetBuildSettings settings)
{
TargetFile = targetFile;
- SourceFiles = sourceFiles;
+ Settings = settings;
RecordModificationDate(targetFile);
- foreach (var sourceFile in sourceFiles)
- RecordModificationDate(sourceFile);
+ foreach (var inputFile in settings.InputFiles)
+ RecordModificationDate(inputFile);
}
private void RecordModificationDate(string file)
View
9 TargetBuildInstructions.cs
@@ -5,7 +5,12 @@ namespace bs
{
public class TargetBuildInstructions
{
- public Action<string, IEnumerable<string>> Action;
- public IEnumerable<string> SourceFiles;
+ public Action<string, TargetBuildSettings> Action;
+ public TargetBuildSettings Settings;
+ }
+
+ public class TargetBuildSettings
+ {
+ public IEnumerable<string> InputFiles;
}
}
View
1  Tests/DependencyGraphTests.cs
@@ -29,5 +29,6 @@ protected void ThrowIfDepgraphGenerates()
{
_depGraph.GenerateCallback += (target, instructions) => { throw new InvalidOperationException(); };
}
+
}
}
View
4 Tests/SimpleCopyDepGraph.cs
@@ -65,8 +65,8 @@ private void SetupSimpleCopyDepGraph()
{
_depGraph.RegisterTarget(defaulttargetFile, new TargetBuildInstructions()
{
- Action = (target,sources) => File.Copy(sources.Single(), target, true),
- SourceFiles = new[] { defaultSourceFile }
+ Action = (target,settings) => File.Copy(settings.InputFiles.Single(), target, true),
+ Settings = new TargetBuildSettings() { InputFiles = new[] { defaultSourceFile }}
});
}
}
View
13 Tests/TargetWithoutSources.cs
@@ -41,20 +41,9 @@ private void SetupGraphWithOneTargetWithoutSources()
_depGraph.RegisterTarget(defaulttargetFile, new TargetBuildInstructions()
{
Action = (target,sources) => File.WriteAllText(target, "Hello"),
- SourceFiles = new string[0],
+ Settings = new TargetBuildSettings() { InputFiles = new string[0]}
});
}
- private static DependencyGraph SetupSimpleCopyDepGraph()
- {
- var depGraph = new DependencyGraph();
-
- depGraph.RegisterTarget(defaulttargetFile, new TargetBuildInstructions()
- {
- Action = (target,sources) => File.Copy(sources.Single(), target, true),
- SourceFiles = new[] { defaultSourceFile }
- });
- return depGraph;
- }
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.