-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathCommand.cs
More file actions
58 lines (51 loc) · 1.28 KB
/
Command.cs
File metadata and controls
58 lines (51 loc) · 1.28 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System;
using System.IO;
namespace DeltaEngine.TestAfterBuild
{
public static class Command
{
private const string CommandFilename = "TestAfterBuild.Command";
private static string userPath;
private static string CommandFilePath
{
get { return Path.Combine(userPath, CommandFilename); }
}
public static string Current = "";
public static int WaitTimeInSeconds = 0;
public static DateTime LastTimeExecuted = new DateTime(2000, 1, 1);
public static bool IsDisabled
{
get
{
return String.IsNullOrEmpty(Current) ||
(DateTime.Now - LastTimeExecuted).TotalSeconds < WaitTimeInSeconds;
}
}
public static void Load(string setUserPath)
{
userPath = setUserPath;
if (File.Exists(CommandFilePath))
ReadTextFromFile();
}
private static void ReadTextFromFile()
{
var file = File.OpenText(CommandFilePath);
Current = file.ReadLine();
WaitTimeInSeconds = 0;
int.TryParse(file.ReadLine(), out WaitTimeInSeconds);
file.Close();
}
public static void Save()
{
var file = File.CreateText(CommandFilePath);
file.WriteLine(Current);
file.WriteLine(WaitTimeInSeconds.ToString());
file.Close();
}
public static void DeleteSaveFile()
{
if (File.Exists(CommandFilePath))
File.Delete(CommandFilePath);
}
}
}