'Stage' auto-generated language class

This commit is contained in:
Ivandro Ismael 2016-02-07 18:51:00 +00:00
parent 212c2f8912
commit f5b3be226c

View File

@ -1,54 +1,54 @@
using System.IO;
using System.Text;
using System.Xml;
// !!! THIS FILE IS AUTO-GENERATED!!!
// !!! THIS FILE IS AUTO-GENERATED!!!
// !!! THIS FILE IS AUTO-GENERATED!!!
namespace Nikse.SubtitleEdit.Core
{
public class LanguageDeserializer // NOTE: This class is AUTO-GENERATED!!!!
{
public static Language CustomDeserializeLanguage(string fileName)
{
var name = new StringBuilder(100, 1000);
var stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
var language = new Language();
using (XmlReader reader = XmlReader.Create(stream, new XmlReaderSettings {
IgnoreWhitespace = true, IgnoreProcessingInstructions = true, IgnoreComments = true,
DtdProcessing = DtdProcessing.Ignore, CheckCharacters = false, CloseInput = true }))
{
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
if (!reader.IsEmptyElement && reader.Depth > 0)
name.Append('/').Append(reader.Name);
else if (reader.Depth == 0)
language.Name = reader["Name"];
}
else if (reader.NodeType == XmlNodeType.EndElement)
{
if (name.Length > 0)
name.Length -= reader.Name.Length + 1;
}
else if (reader.NodeType == XmlNodeType.Text)
{
SetValue(language, reader, name.ToString(1, name.Length - 1));
}
}
}
return language;
}
private static void SetValue(Language language, XmlReader reader, string name)
{
switch (name)
{
using System.IO;
using System.Text;
using System.Xml;
// !!! THIS FILE IS AUTO-GENERATED!!!
// !!! THIS FILE IS AUTO-GENERATED!!!
// !!! THIS FILE IS AUTO-GENERATED!!!
namespace Nikse.SubtitleEdit.Core
{
public class LanguageDeserializer // NOTE: This class is AUTO-GENERATED!!!!
{
public static Language CustomDeserializeLanguage(string fileName)
{
var name = new StringBuilder(100, 1000);
var stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
var language = new Language();
using (XmlReader reader = XmlReader.Create(stream, new XmlReaderSettings {
IgnoreWhitespace = true, IgnoreProcessingInstructions = true, IgnoreComments = true,
DtdProcessing = DtdProcessing.Ignore, CheckCharacters = false, CloseInput = true }))
{
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
if (!reader.IsEmptyElement && reader.Depth > 0)
name.Append('/').Append(reader.Name);
else if (reader.Depth == 0)
language.Name = reader["Name"];
}
else if (reader.NodeType == XmlNodeType.EndElement)
{
if (name.Length > 0)
name.Length -= reader.Name.Length + 1;
}
else if (reader.NodeType == XmlNodeType.Text)
{
SetValue(language, reader, name.ToString(1, name.Length - 1));
}
}
}
return language;
}
private static void SetValue(Language language, XmlReader reader, string name)
{
switch (name)
{
case "Name":
language.Name = reader.Value;
break;