|
|
using System; |
|
|
using System.Collections.Generic; |
|
|
using System.Diagnostics.CodeAnalysis; |
|
|
using System.Linq; |
|
|
|
|
|
namespace VersOne.Epub.Schema |
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public enum EpubMetadataLinkProperty |
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ONIX = 1, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 EpubMetadataLinkPropertyParser |
|
|
{ |
|
|
public static List<EpubMetadataLinkProperty> ParsePropertyList(string stringValue) |
|
|
{ |
|
|
return stringValue.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries). |
|
|
Select(propertyString => ParseProperty(propertyString.Trim())). |
|
|
ToList(); |
|
|
} |
|
|
|
|
|
public static EpubMetadataLinkProperty ParseProperty(string stringValue) |
|
|
{ |
|
|
return stringValue.ToLowerInvariant() switch |
|
|
{ |
|
|
"onix" => EpubMetadataLinkProperty.ONIX, |
|
|
_ => EpubMetadataLinkProperty.UNKNOWN |
|
|
}; |
|
|
} |
|
|
} |
|
|
} |
|
|
|