jellyfin-server/MediaBrowser.Controller/Providers/MetadataResult.cs

67 lines
1.7 KiB
C#
Raw Normal View History

2015-06-29 01:10:45 +00:00
using MediaBrowser.Controller.Entities;
2015-08-02 17:31:08 +00:00
using System;
2015-06-29 01:10:45 +00:00
using System.Collections.Generic;
2015-08-02 17:31:08 +00:00
using System.Linq;
2015-06-29 01:10:45 +00:00
2015-03-13 19:37:19 +00:00
namespace MediaBrowser.Controller.Providers
{
public class MetadataResult<T>
{
2015-08-02 17:31:08 +00:00
public List<LocalImageInfo> Images { get; set; }
public List<UserItemData> UserDataList { get; set; }
public MetadataResult()
{
Images = new List<LocalImageInfo>();
}
2015-06-29 01:10:45 +00:00
public List<PersonInfo> People { get; set; }
2015-03-13 19:37:19 +00:00
public bool HasMetadata { get; set; }
public T Item { get; set; }
2015-06-29 01:10:45 +00:00
2015-07-24 02:48:10 +00:00
public void AddPerson(PersonInfo p)
2015-06-29 01:10:45 +00:00
{
2015-07-24 02:48:10 +00:00
if (People == null)
{
People = new List<PersonInfo>();
}
PeopleHelper.AddPerson(People, p);
}
/// <summary>
/// Not only does this clear, but initializes the list so that services can differentiate between a null list and zero people
/// </summary>
public void ResetPeople()
{
if (People == null)
{
People = new List<PersonInfo>();
}
People.Clear();
2015-06-29 01:10:45 +00:00
}
2015-08-02 17:31:08 +00:00
public UserItemData GetOrAddUserData(string userId)
{
if (UserDataList == null)
{
UserDataList = new List<UserItemData>();
}
var userData = UserDataList.FirstOrDefault(i => string.Equals(userId, i.UserId.ToString("N"), StringComparison.OrdinalIgnoreCase));
if (userData == null)
{
userData = new UserItemData()
{
UserId = new Guid(userId)
};
UserDataList.Add(userData);
}
return userData;
}
2015-03-13 19:37:19 +00:00
}
}