jellyfin/MediaBrowser.Api/HttpHandlers/ItemHandler.cs
LukePulverenti Luke Pulverenti luke pulverenti 5f5f2838b1 moved the http server to common, added more http handlers
2012-07-12 23:50:50 -04:00

54 lines
1.3 KiB
C#

using MediaBrowser.Common.Net;
using MediaBrowser.Common.Net.Handlers;
using MediaBrowser.Model.Entities;
namespace MediaBrowser.Api.HttpHandlers
{
public class ItemHandler : JsonHandler
{
public ItemHandler(RequestContext ctx)
: base(ctx)
{
}
protected sealed override object ObjectToSerialize
{
get
{
return GetSerializationObject(ItemToSerialize, true);
}
}
public static object GetSerializationObject(BaseItem item, bool includeChildren)
{
Folder folder = item as Folder;
if (includeChildren && folder != null)
{
return new
{
BaseItem = item,
Children = folder.Children,
Type = item.GetType().Name
};
}
else
{
return new
{
BaseItem = item,
Type = item.GetType().Name
};
}
}
protected virtual BaseItem ItemToSerialize
{
get
{
return ApiService.GetItemById(QueryString["id"]);
}
}
}
}