-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGenerationRecord.cs
41 lines (34 loc) · 1.05 KB
/
GenerationRecord.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using System.Collections.Generic;
using System.IO;
namespace cake
{
public class GenerationRecord
{
public string TargetFile { get; private set; }
public TargetGenerateSettings Settings { get; private set; }
private readonly Dictionary<string, DateTime> _modificationDates = new Dictionary<string, DateTime>();
public GenerationRecord(string targetFile, TargetGenerateSettings settings)
{
TargetFile = targetFile;
Settings = settings;
RecordModificationDate(targetFile);
foreach (var inputFile in settings.InputFiles)
RecordModificationDate(inputFile);
}
private void RecordModificationDate(string file)
{
if (!File.Exists(file))
throw new ArgumentException("GenerationRecord being generated with inputfile: "+file+" which does not exist.");
_modificationDates.Add(file,File.GetLastWriteTimeUtc(file));
}
public DateTime ModificationTimeOf(string file)
{
return _modificationDates[file];
}
public DateTime ModificationTimeOfTargetFile()
{
return ModificationTimeOf(TargetFile);
}
}
}