diff --git a/Advapi32.cs b/Advapi32.cs index f3b569d..4f8bb94 100755 --- a/Advapi32.cs +++ b/Advapi32.cs @@ -255,10 +255,10 @@ namespace Advapi32 /// public uint Delay; - public SC_ACTION(SC_ACTION_TYPE type, uint delay) + public SC_ACTION(SC_ACTION_TYPE type, TimeSpan delay) { this.Type = type; - this.Delay = delay; + this.Delay = (uint)delay.TotalMilliseconds; } } diff --git a/ServiceDescriptor.cs b/ServiceDescriptor.cs index 8c2dd2a..2dfd600 100755 --- a/ServiceDescriptor.cs +++ b/ServiceDescriptor.cs @@ -108,17 +108,23 @@ namespace winsw } else { - string v = e.InnerText; - foreach (var s in SUFFIX) { - if (v.EndsWith(s.Key)) - { - return TimeSpan.FromMilliseconds(int.Parse(v.Substring(0,v.Length-s.Key.Length).Trim())*s.Value); - } - } - return TimeSpan.FromMilliseconds(int.Parse(v)); + return ParseTimeSpan(e.InnerText); } } + private TimeSpan ParseTimeSpan(string v) + { + v = v.Trim(); + foreach (var s in SUFFIX) + { + if (v.EndsWith(s.Key)) + { + return TimeSpan.FromMilliseconds(int.Parse(v.Substring(0, v.Length - s.Key.Length).Trim()) * s.Value); + } + } + return TimeSpan.FromMilliseconds(int.Parse(v)); + } + private static readonly Dictionary SUFFIX = new Dictionary { { "ms", 1 }, { "sec", 1000L }, @@ -491,7 +497,7 @@ namespace winsw throw new Exception("Invalid failure action: " + action); } XmlAttribute delay = n.Attributes["delay"]; - r.Add(new SC_ACTION(type, delay!=null ? uint.Parse(delay.Value) : 0)); + r.Add(new SC_ACTION(type, delay != null ? ParseTimeSpan(delay.Value) : TimeSpan.Zero)); } return r; }