jellyfin-server/MediaBrowser.Api/HttpHandlers/ItemHandler.cs

50 lines
1.2 KiB
C#
Raw Normal View History

using MediaBrowser.Common.Net;
using MediaBrowser.Common.Net.Handlers;
2012-07-12 06:55:27 +00:00
using MediaBrowser.Model.Entities;
using MediaBrowser.Common.Json;
2012-07-12 06:55:27 +00:00
namespace MediaBrowser.Api.HttpHandlers
{
public class ItemHandler : JsonHandler
2012-07-12 06:55:27 +00:00
{
public ItemHandler(RequestContext ctx)
: base(ctx)
{
}
protected sealed override object ObjectToSerialize
2012-07-12 06:55:27 +00:00
{
get
{
return GetSerializationObject(ItemToSerialize, true);
2012-07-12 06:55:27 +00:00
}
}
public static object GetSerializationObject(BaseItem item, bool includeChildren)
2012-07-12 06:55:27 +00:00
{
if (includeChildren && item.IsFolder)
2012-07-12 06:55:27 +00:00
{
Folder folder = item as Folder;
return new
2012-07-12 06:55:27 +00:00
{
BaseItem = item,
Children = folder.Children
2012-07-12 06:55:27 +00:00
};
}
else
{
return item;
2012-07-12 06:55:27 +00:00
}
}
protected virtual BaseItem ItemToSerialize
2012-07-12 06:55:27 +00:00
{
get
2012-07-12 06:55:27 +00:00
{
return ApiService.GetItemById(QueryString["id"]);
2012-07-12 06:55:27 +00:00
}
}
}
}