|
|
using System; |
|
|
using System.Diagnostics.CodeAnalysis; |
|
|
|
|
|
namespace VersOne.Epub.Schema |
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public enum EpubTextDirection |
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
LEFT_TO_RIGHT, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RIGHT_TO_LEFT, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AUTO, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UNKNOWN |
|
|
} |
|
|
|
|
|
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1649:File name should match first type name", |
|
|
Justification = "Enum and parser need to be close to each other to avoid issues when the enum was changed without changing the parser. The file needs to be named after enum.")] |
|
|
internal static class EpubTextDirectionParser |
|
|
{ |
|
|
public static EpubTextDirection Parse(string stringValue) |
|
|
{ |
|
|
if (String.IsNullOrEmpty(stringValue)) |
|
|
{ |
|
|
return EpubTextDirection.UNKNOWN; |
|
|
} |
|
|
return stringValue.ToLowerInvariant() switch |
|
|
{ |
|
|
"ltr" => EpubTextDirection.LEFT_TO_RIGHT, |
|
|
"rtl" => EpubTextDirection.RIGHT_TO_LEFT, |
|
|
"auto" => EpubTextDirection.AUTO, |
|
|
_ => EpubTextDirection.UNKNOWN |
|
|
}; |
|
|
} |
|
|
} |
|
|
} |
|
|
|