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

54 lines
1.3 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;
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
{
Folder folder = item as Folder;
if (includeChildren && folder != null)
2012-07-12 06:55:27 +00:00
{
return new
2012-07-12 06:55:27 +00:00
{
BaseItem = item,
Children = folder.Children,
Type = item.GetType().Name
2012-07-12 06:55:27 +00:00
};
}
else
{
return new
2012-07-12 06:55:27 +00:00
{
BaseItem = item,
Type = item.GetType().Name
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
}
}
}
}