Switched to service stack json. Added more api enhancements.

This commit is contained in:
LukePulverenti Luke Pulverenti luke pulverenti
2012-07-15 16:27:07 -04:00
parent 2e03cb0916
commit baedafbeb9
27 changed files with 370 additions and 142 deletions

View File

@@ -1,4 +1,4 @@
using MediaBrowser.Common.Logging;
using MediaBrowser.Model.Logging;
namespace MediaBrowser.Model.Configuration
{
@@ -11,7 +11,7 @@ namespace MediaBrowser.Model.Configuration
public Configuration()
{
HttpServerPortNumber = 8096;
LogSeverity = Common.Logging.LogSeverity.Info;
LogSeverity = LogSeverity.Info;
}
}
}

View File

@@ -1,65 +1,85 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using System.Runtime.Serialization;
namespace MediaBrowser.Model.Entities
{
public abstract class BaseItem
{
public string Name { get; set; }
public string SortName { get; set; }
public virtual string Name { get; set; }
public virtual string SortName { get; set; }
public Guid Id { get; set; }
public virtual Guid Id { get; set; }
public DateTime DateCreated { get; set; }
public DateTime DateModified { get; set; }
public virtual DateTime DateCreated { get; set; }
public string Path { get; set; }
public virtual DateTime DateModified { get; set; }
[JsonIgnore]
public virtual string Path { get; set; }
[IgnoreDataMember]
public Folder Parent { get; set; }
public string PrimaryImagePath { get; set; }
public string LogoImagePath { get; set; }
public string ArtImagePath { get; set; }
public string ThumbnailImagePath { get; set; }
public string BannerImagePath { get; set; }
public virtual string PrimaryImagePath { get; set; }
public virtual string LogoImagePath { get; set; }
public virtual string ArtImagePath { get; set; }
public virtual string ThumbnailImagePath { get; set; }
public virtual string BannerImagePath { get; set; }
public IEnumerable<string> BackdropImagePaths { get; set; }
public virtual IEnumerable<string> BackdropImagePaths { get; set; }
public string OfficialRating { get; set; }
public virtual string OfficialRating { get; set; }
public string CustomRating { get; set; }
public string CustomPin { get; set; }
public virtual string CustomRating { get; set; }
public virtual string CustomPin { get; set; }
public string Overview { get; set; }
public string Tagline { get; set; }
public virtual string Overview { get; set; }
public virtual string Tagline { get; set; }
[JsonIgnore]
public IEnumerable<PersonInfo> People { get; set; }
[IgnoreDataMember]
public virtual IEnumerable<PersonInfo> People { get; set; }
public IEnumerable<string> Studios { get; set; }
public virtual IEnumerable<string> Studios { get; set; }
public IEnumerable<string> Genres { get; set; }
public virtual IEnumerable<string> Genres { get; set; }
public string DisplayMediaType { get; set; }
public virtual string DisplayMediaType { get; set; }
public float? UserRating { get; set; }
public TimeSpan? RunTime { get; set; }
public virtual float? UserRating { get; set; }
public virtual TimeSpan? RunTime { get; set; }
public string AspectRatio { get; set; }
public int? ProductionYear { get; set; }
public virtual string AspectRatio { get; set; }
public virtual int? ProductionYear { get; set; }
public IEnumerable<Video> LocalTrailers { get; set; }
public string TrailerUrl { get; set; }
public virtual IEnumerable<Video> LocalTrailers { get; set; }
public virtual string TrailerUrl { get; set; }
public override string ToString()
{
return Name;
}
/// <summary>
/// This is strictly to enhance json output, until I can find a way to customize service stack to add this without having to use a property
/// </summary>
public virtual bool IsFolder
{
get
{
return false;
}
}
/// <summary>
/// This is strictly to enhance json output, until I can find a way to customize service stack to add this without having to use a property
/// </summary>
public string Type
{
get
{
return GetType().Name;
}
}
}
}

View File

@@ -1,10 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Newtonsoft.Json;
using System.Linq;
using System.Runtime.Serialization;
namespace MediaBrowser.Model.Entities
{
@@ -20,10 +18,18 @@ namespace MediaBrowser.Model.Entities
}
}
[JsonIgnore]
public override bool IsFolder
{
get
{
return true;
}
}
[IgnoreDataMember]
public BaseItem[] Children { get; set; }
[JsonIgnore]
[IgnoreDataMember]
public IEnumerable<Folder> FolderChildren { get { return Children.OfType<Folder>(); } }
public Folder GetFolderByName(string name)

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MediaBrowser.Model.Logging
{
[Flags]
public enum LogSeverity
{
None = 0,
Debug = 1,
Info = 2,
Warning = 4,
Error = 8
}
}

View File

@@ -30,11 +30,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.4.5.7\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
@@ -48,20 +46,12 @@
<Compile Include="Entities\BaseItem.cs" />
<Compile Include="Entities\Folder.cs" />
<Compile Include="Entities\PlaybackStatus.cs" />
<Compile Include="Logging\LogSeverity.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Users\User.cs" />
<Compile Include="Users\UserItemData.cs" />
<Compile Include="Entities\Video.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MediaBrowser.Common\MediaBrowser.Common.csproj">
<Project>{9142eefa-7570-41e1-bfcc-468bb571af2f}</Project>
<Name>MediaBrowser.Common</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View File

@@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="4.5.7" targetFramework="net45" />
</packages>