Deserialize with the correct type (and warning fixes)
This commit is contained in:
parent
ef623f5129
commit
846857b60e
|
@ -3,10 +3,8 @@ using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.Serialization;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Serialization;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Emby.Server.Implementations.Playlists;
|
using Emby.Server.Implementations.Playlists;
|
||||||
using MediaBrowser.Common.Json;
|
using MediaBrowser.Common.Json;
|
||||||
|
@ -28,7 +26,6 @@ using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.Model.Globalization;
|
using MediaBrowser.Model.Globalization;
|
||||||
using MediaBrowser.Model.LiveTv;
|
using MediaBrowser.Model.LiveTv;
|
||||||
using MediaBrowser.Model.Querying;
|
using MediaBrowser.Model.Querying;
|
||||||
using MediaBrowser.Model.Serialization;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using SQLitePCL.pretty;
|
using SQLitePCL.pretty;
|
||||||
|
|
||||||
|
@ -659,12 +656,14 @@ namespace Emby.Server.Implementations.Data
|
||||||
|
|
||||||
private void SaveItem(BaseItem item, BaseItem topParent, string userDataKey, IStatement saveItemStatement)
|
private void SaveItem(BaseItem item, BaseItem topParent, string userDataKey, IStatement saveItemStatement)
|
||||||
{
|
{
|
||||||
saveItemStatement.TryBind("@guid", item.Id);
|
Type type = item.GetType();
|
||||||
saveItemStatement.TryBind("@type", item.GetType().FullName);
|
|
||||||
|
|
||||||
if (TypeRequiresDeserialization(item.GetType()))
|
saveItemStatement.TryBind("@guid", item.Id);
|
||||||
|
saveItemStatement.TryBind("@type", type.FullName);
|
||||||
|
|
||||||
|
if (TypeRequiresDeserialization(type))
|
||||||
{
|
{
|
||||||
saveItemStatement.TryBind("@data", JsonSerializer.SerializeToUtf8Bytes(item, _jsonOptions));
|
saveItemStatement.TryBind("@data", JsonSerializer.SerializeToUtf8Bytes(item, type, _jsonOptions));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -2175,7 +2175,6 @@ namespace Emby.Server.Implementations.Library
|
||||||
DisplayParentId = parentId
|
DisplayParentId = parentId
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
CreateItem(item, null);
|
CreateItem(item, null);
|
||||||
|
|
||||||
isNew = true;
|
isNew = true;
|
||||||
|
@ -2197,7 +2196,6 @@ namespace Emby.Server.Implementations.Library
|
||||||
{
|
{
|
||||||
// Need to force save to increment DateLastSaved
|
// Need to force save to increment DateLastSaved
|
||||||
ForceSave = true
|
ForceSave = true
|
||||||
|
|
||||||
},
|
},
|
||||||
RefreshPriority.Normal);
|
RefreshPriority.Normal);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,11 @@ namespace MediaBrowser.Controller.Entities
|
||||||
public interface ICollectionFolder : IHasCollectionType
|
public interface ICollectionFolder : IHasCollectionType
|
||||||
{
|
{
|
||||||
string Path { get; }
|
string Path { get; }
|
||||||
|
|
||||||
string Name { get; }
|
string Name { get; }
|
||||||
|
|
||||||
Guid Id { get; }
|
Guid Id { get; }
|
||||||
|
|
||||||
string[] PhysicalLocations { get; }
|
string[] PhysicalLocations { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,34 +10,36 @@ namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
public class UserView : Folder, IHasCollectionType
|
public class UserView : Folder, IHasCollectionType
|
||||||
{
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
public string ViewType { get; set; }
|
public string ViewType { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public new Guid DisplayParentId { get; set; }
|
public new Guid DisplayParentId { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public Guid? UserId { get; set; }
|
public Guid? UserId { get; set; }
|
||||||
|
|
||||||
public static ITVSeriesManager TVSeriesManager;
|
public static ITVSeriesManager TVSeriesManager;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public string CollectionType => ViewType;
|
public string CollectionType => ViewType;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public override IEnumerable<Guid> GetIdsForAncestorQuery()
|
public override IEnumerable<Guid> GetIdsForAncestorQuery()
|
||||||
{
|
{
|
||||||
var list = new List<Guid>();
|
|
||||||
|
|
||||||
if (!DisplayParentId.Equals(Guid.Empty))
|
if (!DisplayParentId.Equals(Guid.Empty))
|
||||||
{
|
{
|
||||||
list.Add(DisplayParentId);
|
yield return DisplayParentId;
|
||||||
}
|
}
|
||||||
else if (!ParentId.Equals(Guid.Empty))
|
else if (!ParentId.Equals(Guid.Empty))
|
||||||
{
|
{
|
||||||
list.Add(ParentId);
|
yield return ParentId;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
list.Add(Id);
|
yield return Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user