jellyfin-server/MediaBrowser.Providers/Games/GameSystemXmlParser.cs

65 lines
1.9 KiB
C#
Raw Normal View History

2014-02-02 13:36:31 +00:00
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
using System.Threading;
using System.Threading.Tasks;
using System.Xml;
namespace MediaBrowser.Providers.Games
{
public class GameSystemXmlParser : BaseItemXmlParser<GameSystem>
{
public GameSystemXmlParser(ILogger logger)
: base(logger)
{
}
2014-02-03 17:44:13 +00:00
private readonly Task _cachedTask = Task.FromResult(true);
2014-02-02 13:36:31 +00:00
public Task FetchAsync(GameSystem item, string metadataFile, CancellationToken cancellationToken)
{
Fetch(item, metadataFile, cancellationToken);
cancellationToken.ThrowIfCancellationRequested();
2014-02-03 17:44:13 +00:00
return _cachedTask;
2014-02-02 13:36:31 +00:00
}
/// <summary>
/// Fetches the data from XML node.
/// </summary>
/// <param name="reader">The reader.</param>
/// <param name="item">The item.</param>
protected override void FetchDataFromXmlNode(XmlReader reader, GameSystem item)
{
switch (reader.Name)
{
case "GameSystem":
{
var val = reader.ReadElementContentAsString();
if (!string.IsNullOrWhiteSpace(val))
{
item.GameSystemName = val;
}
break;
}
case "GamesDbId":
{
var val = reader.ReadElementContentAsString();
if (!string.IsNullOrWhiteSpace(val))
{
item.SetProviderId(MetadataProviders.Gamesdb, val);
}
break;
}
default:
base.FetchDataFromXmlNode(reader, item);
break;
}
}
}
}