|
@@ -47,7 +47,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
|
|
|
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- return _jsonSerializer.DeserializeFromFile<List<T>>(jsonFile);
|
|
|
|
|
|
+ return _jsonSerializer.DeserializeFromFile<List<T>>(jsonFile) ?? new List<T>();
|
|
}
|
|
}
|
|
catch (FileNotFoundException)
|
|
catch (FileNotFoundException)
|
|
{
|
|
{
|
|
@@ -69,6 +69,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
|
|
|
|
|
private void UpdateList(List<T> newList)
|
|
private void UpdateList(List<T> newList)
|
|
{
|
|
{
|
|
|
|
+ if (newList == null)
|
|
|
|
+ {
|
|
|
|
+ throw new ArgumentNullException("newList");
|
|
|
|
+ }
|
|
|
|
+
|
|
var file = _dataPath + ".json";
|
|
var file = _dataPath + ".json";
|
|
_fileSystem.CreateDirectory(Path.GetDirectoryName(file));
|
|
_fileSystem.CreateDirectory(Path.GetDirectoryName(file));
|
|
|
|
|
|
@@ -81,6 +86,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
|
|
|
|
|
public virtual void Update(T item)
|
|
public virtual void Update(T item)
|
|
{
|
|
{
|
|
|
|
+ if (item == null)
|
|
|
|
+ {
|
|
|
|
+ throw new ArgumentNullException("item");
|
|
|
|
+ }
|
|
|
|
+
|
|
var list = GetAll().ToList();
|
|
var list = GetAll().ToList();
|
|
|
|
|
|
var index = list.FindIndex(i => EqualityComparer(i, item));
|
|
var index = list.FindIndex(i => EqualityComparer(i, item));
|
|
@@ -97,6 +107,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
|
|
|
|
|
public virtual void Add(T item)
|
|
public virtual void Add(T item)
|
|
{
|
|
{
|
|
|
|
+ if (item == null)
|
|
|
|
+ {
|
|
|
|
+ throw new ArgumentNullException("item");
|
|
|
|
+ }
|
|
|
|
+
|
|
var list = GetAll().ToList();
|
|
var list = GetAll().ToList();
|
|
|
|
|
|
if (list.Any(i => EqualityComparer(i, item)))
|
|
if (list.Any(i => EqualityComparer(i, item)))
|