mirror of https://github.com/winsw/winsw
Validatation method seperated
parent
a56f2290e9
commit
fd961fec4d
|
@ -67,8 +67,11 @@ namespace winsw
|
|||
|
||||
try
|
||||
{
|
||||
string xmlstring = File.ReadAllText(BasePath + ".xml");
|
||||
dom = ServiceDescriptor.FromXML(xmlstring).dom;
|
||||
using(var reader = new StreamReader(BasePath + ".xml"))
|
||||
{
|
||||
string xml = reader.ReadToEnd();
|
||||
dom = ServiceDescriptor.XmlValidation(xml);
|
||||
}
|
||||
}
|
||||
catch (XmlException e)
|
||||
{
|
||||
|
@ -105,7 +108,12 @@ namespace winsw
|
|||
// ReSharper disable once InconsistentNaming
|
||||
public static ServiceDescriptor FromXML(string xml)
|
||||
{
|
||||
var dom = new XmlDocument();
|
||||
return new ServiceDescriptor(XmlValidation(xml));
|
||||
}
|
||||
|
||||
|
||||
public static XmlDocument XmlValidation(string xml)
|
||||
{
|
||||
XmlReaderSettings settings = new XmlReaderSettings();
|
||||
Assembly a = Assembly.GetExecutingAssembly();
|
||||
|
||||
|
@ -127,10 +135,12 @@ namespace winsw
|
|||
|
||||
var reader = XmlReader.Create(new StringReader(xml), settings);
|
||||
|
||||
dom.Load(reader);
|
||||
return new ServiceDescriptor(dom);
|
||||
var xmlDoc = new XmlDocument();
|
||||
xmlDoc.Load(reader);
|
||||
return xmlDoc;
|
||||
}
|
||||
|
||||
|
||||
private string SingleElement(string tagName)
|
||||
{
|
||||
return SingleElement(tagName, false)!;
|
||||
|
|
|
@ -446,7 +446,7 @@ $@"<service>
|
|||
}
|
||||
|
||||
[Test]
|
||||
public void FromXMLTest()
|
||||
public void XmlValidationTest()
|
||||
{
|
||||
const string seedXml = @"<id>
|
||||
<id>myapp</id>
|
||||
|
@ -456,7 +456,7 @@ $@"<service>
|
|||
</id>
|
||||
";
|
||||
|
||||
Assert.That(() => ServiceDescriptor.FromXML(seedXml), Throws.Exception.TypeOf<XmlException>());
|
||||
Assert.That(() => ServiceDescriptor.XmlValidation(seedXml), Throws.Exception.TypeOf<XmlException>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue