You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jellyfin/MediaBrowser.Controller/Providers/MetadataResult.cs

100 lines
2.5 KiB

#nullable disable
#pragma warning disable CA1002, CA2227, CS1591
6 years ago
using System;
using System.Collections.Generic;
using System.Globalization;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Entities;
6 years ago
namespace MediaBrowser.Controller.Providers
{
public class MetadataResult<T>
{
// Images aren't always used so the allocation is a waste a lot of the time
private List<LocalImageInfo> _images;
private List<(string Url, ImageType Type)> _remoteImages;
6 years ago
public MetadataResult()
{
ResultLanguage = "en";
}
public List<LocalImageInfo> Images
{
get => _images ??= new List<LocalImageInfo>();
set => _images = value;
}
public List<(string Url, ImageType Type)> RemoteImages
{
get => _remoteImages ??= new List<(string Url, ImageType Type)>();
set => _remoteImages = value;
}
public List<UserItemData> UserDataList { get; set; }
6 years ago
public List<PersonInfo> People { get; set; }
public bool HasMetadata { get; set; }
6 years ago
public T Item { get; set; }
6 years ago
public string ResultLanguage { get; set; }
6 years ago
public string Provider { get; set; }
6 years ago
public bool QueriedById { get; set; }
6 years ago
public void AddPerson(PersonInfo p)
{
People ??= new List<PersonInfo>();
6 years ago
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.
6 years ago
/// </summary>
public void ResetPeople()
{
if (People is null)
6 years ago
{
People = new List<PersonInfo>();
}
else
{
People.Clear();
}
6 years ago
}
public UserItemData GetOrAddUserData(string userId)
{
UserDataList ??= new List<UserItemData>();
6 years ago
UserItemData userData = null;
foreach (var i in UserDataList)
{
if (string.Equals(userId, i.UserId.ToString("N", CultureInfo.InvariantCulture), StringComparison.OrdinalIgnoreCase))
6 years ago
{
userData = i;
}
}
if (userData is null)
6 years ago
{
userData = new UserItemData()
{
UserId = new Guid(userId)
};
UserDataList.Add(userData);
}
return userData;
}
}
6 years ago
}