using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
namespace VersOne.Epub.Schema
{
///
/// Property that describes the relationship between the resource referenced by and the EPUB book.
/// See for more information.
///
public enum EpubMetadataLinkRelationship
{
///
/// The 'alternate' property. Identifies an alternate representation of the EPUB book or a collection.
/// See for more information.
///
ALTERNATE = 1,
///
/// The 'marc21xml-record' property. Indicates that the referenced resource is a MARC21 record.
///
/// See
/// and for more information.
///
///
MARC21XML_RECORD,
///
/// The 'mods-record' property. Indicates that the referenced resource is a MODS record.
///
/// See
/// and for more information.
///
///
MODS_RECORD,
///
/// The 'onix-record' property. Indicates that the referenced resource is an ONIX record.
///
/// See
/// and for more information.
///
///
ONIX_RECORD,
///
/// The 'record' property. Indicates that the referenced resource is a metadata record.
/// See for more information.
///
RECORD,
///
///
/// The 'voicing' property. Indicates that the referenced audio file provides an aural representation of the expression or resource (typically, the title or creator)
/// specified by the property.
///
/// See for more information.
///
VOICING,
///
/// The 'xml-signature' property. Indicates that the referenced resource contains an XML Signature for the EPUB book or associated property.
///
/// See
/// and for more information.
///
///
XML_SIGNATURE,
///
/// The 'xmp-record' property. Indicates that the referenced resource is an XMP record.
///
/// See
/// and for more information.
///
///
XMP_RECORD,
///
/// A relationship which is not present in this enumeration.
///
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 EpubMetadataLinkRelationshipParser
{
public static List ParseRelationshipList(string stringValue)
{
return stringValue.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).
Select(relationshipString => ParseRelationship(relationshipString.Trim())).
ToList();
}
public static EpubMetadataLinkRelationship ParseRelationship(string stringValue)
{
return stringValue.ToLowerInvariant() switch
{
"alternate" => EpubMetadataLinkRelationship.ALTERNATE,
"marc21xml-record" => EpubMetadataLinkRelationship.MARC21XML_RECORD,
"mods-record" => EpubMetadataLinkRelationship.MODS_RECORD,
"onix-record" => EpubMetadataLinkRelationship.ONIX_RECORD,
"record" => EpubMetadataLinkRelationship.RECORD,
"voicing" => EpubMetadataLinkRelationship.VOICING,
"xml-signature" => EpubMetadataLinkRelationship.XML_SIGNATURE,
"xmp-record" => EpubMetadataLinkRelationship.XMP_RECORD,
_ => EpubMetadataLinkRelationship.UNKNOWN
};
}
}
}