Extract out FileTypes namespace

This commit is contained in:
Matt Nadareski
2020-12-08 14:53:49 -08:00
parent 0512e393c8
commit 82e3a3939b
134 changed files with 500 additions and 641 deletions

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Xml;
using System.Xml.Schema;
namespace SabreTools.Skippers
{
@@ -59,7 +60,16 @@ namespace SabreTools.Skippers
Rules = new List<SkipperRule>();
SourceFile = Path.GetFileNameWithoutExtension(filename);
XmlReader xtr = GetXmlTextReader(filename);
XmlReader xtr = XmlReader.Create(filename, new XmlReaderSettings
{
CheckCharacters = false,
DtdProcessing = DtdProcessing.Ignore,
IgnoreComments = true,
IgnoreWhitespace = true,
ValidationFlags = XmlSchemaValidationFlags.None,
ValidationType = ValidationType.None,
});
bool valid = Parse(xtr);
// If we somehow have an invalid file, zero out the fields
@@ -410,34 +420,5 @@ namespace SabreTools.Skippers
}
#endregion
// TODO: Remove this region once IO namespace is separated out properly
#region TEMPORARY - REMOVEME
/// <summary>
/// Get the XmlTextReader associated with a file, if possible
/// </summary>
/// <param name="filename">Name of the file to be parsed</param>
/// <returns>The XmlTextReader representing the (possibly converted) file, null otherwise</returns>
private static XmlReader GetXmlTextReader(string filename)
{
// Check if file exists
if (!File.Exists(filename))
return null;
XmlReader xtr = XmlReader.Create(filename, new XmlReaderSettings
{
CheckCharacters = false,
DtdProcessing = DtdProcessing.Ignore,
IgnoreComments = true,
IgnoreWhitespace = true,
ValidationFlags = System.Xml.Schema.XmlSchemaValidationFlags.None,
ValidationType = ValidationType.None,
});
return xtr;
}
#endregion
}
}