jellyfin/MediaBrowser.LocalMetadata/Savers/GameSystemXmlSaver.cs

60 lines
1.9 KiB
C#
Raw Normal View History

using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using System.Collections.Generic;
2013-09-26 15:15:18 +00:00
using System.IO;
2016-10-28 19:56:54 +00:00
using System.Xml;
2016-10-25 19:02:04 +00:00
using MediaBrowser.Model.IO;
2016-10-28 19:56:54 +00:00
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Xml;
2013-09-26 15:15:18 +00:00
namespace MediaBrowser.LocalMetadata.Savers
2013-09-26 15:15:18 +00:00
{
2016-10-28 19:56:54 +00:00
public class GameSystemXmlSaver : BaseXmlSaver
2013-09-26 15:15:18 +00:00
{
2016-10-28 19:56:54 +00:00
public GameSystemXmlSaver(IFileSystem fileSystem, IServerConfigurationManager configurationManager, ILibraryManager libraryManager, IUserManager userManager, IUserDataManager userDataManager, ILogger logger, IXmlReaderSettingsFactory xmlReaderSettingsFactory) : base(fileSystem, configurationManager, libraryManager, userManager, userDataManager, logger, xmlReaderSettingsFactory)
2014-02-02 13:36:31 +00:00
{
}
2016-10-28 19:56:54 +00:00
public override bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType)
2013-09-26 15:15:18 +00:00
{
2014-02-10 20:11:46 +00:00
if (!item.SupportsLocalMetadata)
2014-02-08 20:02:35 +00:00
{
return false;
}
2014-02-11 21:41:01 +00:00
return item is GameSystem && updateType >= ItemUpdateType.MetadataDownload;
2013-09-26 15:15:18 +00:00
}
2016-10-28 19:56:54 +00:00
protected override List<string> GetTagsUsed()
2013-09-26 15:15:18 +00:00
{
2016-10-28 19:56:54 +00:00
var list = new List<string>
{
"GameSystem"
};
2014-02-02 13:36:31 +00:00
2016-10-28 19:56:54 +00:00
return list;
}
2013-09-26 15:15:18 +00:00
2016-10-28 19:56:54 +00:00
protected override void WriteCustomElements(IHasMetadata item, XmlWriter writer)
{
var gameSystem = (GameSystem)item;
2013-09-26 15:15:18 +00:00
2014-02-02 13:36:31 +00:00
if (!string.IsNullOrEmpty(gameSystem.GameSystemName))
{
2016-10-28 19:56:54 +00:00
writer.WriteElementString("GameSystem", gameSystem.GameSystemName);
2014-02-02 13:36:31 +00:00
}
2013-09-26 15:15:18 +00:00
}
2016-10-28 19:56:54 +00:00
protected override string GetLocalSavePath(IHasMetadata item)
2013-09-26 15:15:18 +00:00
{
return Path.Combine(item.Path, "gamesystem.xml");
}
2016-10-28 19:56:54 +00:00
protected override string GetRootElementName(IHasMetadata item)
{
return "Item";
}
2013-09-26 15:15:18 +00:00
}
}