2019-01-13 13:02:23 -07:00
|
|
|
using System.IO;
|
2019-01-13 12:25:45 -07:00
|
|
|
using System.Xml;
|
|
|
|
using MediaBrowser.Controller.Configuration;
|
2014-09-05 21:21:23 -07:00
|
|
|
using MediaBrowser.Controller.Entities;
|
|
|
|
using MediaBrowser.Controller.Library;
|
2016-10-25 12:02:04 -07:00
|
|
|
using MediaBrowser.Model.IO;
|
2016-10-28 12:56:54 -07:00
|
|
|
using MediaBrowser.Model.Xml;
|
2019-01-13 12:25:45 -07:00
|
|
|
using Microsoft.Extensions.Logging;
|
2013-09-26 08:15:18 -07:00
|
|
|
|
2014-06-29 20:04:50 -07:00
|
|
|
namespace MediaBrowser.LocalMetadata.Savers
|
2013-09-26 08:15:18 -07:00
|
|
|
{
|
2016-10-28 12:56:54 -07:00
|
|
|
public class GameSystemXmlSaver : BaseXmlSaver
|
2013-09-26 08:15:18 -07:00
|
|
|
{
|
2016-10-28 12:56:54 -07: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 06:36:31 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-09-12 10:26:21 -07:00
|
|
|
public override bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
|
2013-09-26 08:15:18 -07:00
|
|
|
{
|
2014-02-10 13:11:46 -07:00
|
|
|
if (!item.SupportsLocalMetadata)
|
2014-02-08 13:02:35 -07:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-02-11 14:41:01 -07:00
|
|
|
return item is GameSystem && updateType >= ItemUpdateType.MetadataDownload;
|
2013-09-26 08:15:18 -07:00
|
|
|
}
|
|
|
|
|
2018-09-12 10:26:21 -07:00
|
|
|
protected override void WriteCustomElements(BaseItem item, XmlWriter writer)
|
2016-10-28 12:56:54 -07:00
|
|
|
{
|
|
|
|
var gameSystem = (GameSystem)item;
|
2013-09-26 08:15:18 -07:00
|
|
|
|
2014-02-02 06:36:31 -07:00
|
|
|
if (!string.IsNullOrEmpty(gameSystem.GameSystemName))
|
|
|
|
{
|
2016-10-28 12:56:54 -07:00
|
|
|
writer.WriteElementString("GameSystem", gameSystem.GameSystemName);
|
2014-02-02 06:36:31 -07:00
|
|
|
}
|
2013-09-26 08:15:18 -07:00
|
|
|
}
|
|
|
|
|
2018-09-12 10:26:21 -07:00
|
|
|
protected override string GetLocalSavePath(BaseItem item)
|
2013-09-26 08:15:18 -07:00
|
|
|
{
|
|
|
|
return Path.Combine(item.Path, "gamesystem.xml");
|
|
|
|
}
|
2016-10-28 12:56:54 -07:00
|
|
|
|
2018-09-12 10:26:21 -07:00
|
|
|
protected override string GetRootElementName(BaseItem item)
|
2016-10-28 12:56:54 -07:00
|
|
|
{
|
|
|
|
return "Item";
|
|
|
|
}
|
2013-09-26 08:15:18 -07:00
|
|
|
}
|
|
|
|
}
|