Refactoring: Null checks for getters in ServiceDescriptor (broken XmlDocument)

Signed-off-by: Oleg Nenashev <o.v.nenashev@gmail.com>
pull/75/head
Oleg Nenashev 2015-01-31 12:38:48 +03:00
parent 9291ac911c
commit b95f6f6d5c
1 changed files with 34 additions and 25 deletions

View File

@ -75,6 +75,7 @@ namespace winsw
this.dom = dom;
}
// ReSharper disable once InconsistentNaming
public static ServiceDescriptor FromXML(string xml)
{
var dom = new XmlDocument();
@ -357,7 +358,9 @@ namespace winsw
{
ArrayList serviceDependencies = new ArrayList();
foreach (XmlNode depend in dom.SelectNodes("//depend"))
var xmlNodeList = dom.SelectNodes("//depend");
if (xmlNodeList != null)
foreach (XmlNode depend in xmlNodeList)
{
serviceDependencies.Add(depend.InnerText);
}
@ -470,7 +473,9 @@ namespace winsw
get
{
List<Download> r = new List<Download>();
foreach (XmlNode n in dom.SelectNodes("//download"))
var xmlNodeList = dom.SelectNodes("//download");
if (xmlNodeList != null)
foreach (XmlNode n in xmlNodeList)
{
r.Add(new Download(n));
}
@ -483,7 +488,10 @@ namespace winsw
get
{
List<SC_ACTION> r = new List<SC_ACTION>();
foreach (XmlNode n in dom.SelectNodes("//onfailure"))
var childNodes = dom.SelectNodes("//onfailure");
if (childNodes != null)
{
foreach (XmlNode n in childNodes)
{
SC_ACTION_TYPE type;
string action = n.Attributes["action"].Value;
@ -504,6 +512,7 @@ namespace winsw
XmlAttribute delay = n.Attributes["delay"];
r.Add(new SC_ACTION(type, delay != null ? ParseTimeSpan(delay.Value) : TimeSpan.Zero));
}
}
return r;
}
}