|
|
@ -1,4 +1,5 @@
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Threading;
|
|
|
|
using System.Threading;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using System.Threading.Tasks;
|
|
|
@ -61,5 +62,46 @@ namespace MediaBrowser.Controller.Entities
|
|
|
|
item.SetImagePath(imageType, BaseItem.FileSystem.GetFileInfo(file));
|
|
|
|
item.SetImagePath(imageType, BaseItem.FileSystem.GetFileInfo(file));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// Copies all properties on object. Skips properties that do not exist.
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="source">The source object.</param>
|
|
|
|
|
|
|
|
/// <param name="dest">The destination object.</param>
|
|
|
|
|
|
|
|
public static void DeepCopy<T, TU>(this T source, TU dest)
|
|
|
|
|
|
|
|
where T : BaseItem
|
|
|
|
|
|
|
|
where TU : BaseItem
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var sourceProps = typeof (T).GetProperties().Where(x => x.CanRead).ToList();
|
|
|
|
|
|
|
|
var destProps = typeof(TU).GetProperties()
|
|
|
|
|
|
|
|
.Where(x => x.CanWrite)
|
|
|
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var sourceProp in sourceProps)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (destProps.Any(x => x.Name == sourceProp.Name))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var p = destProps.First(x => x.Name == sourceProp.Name);
|
|
|
|
|
|
|
|
p.SetValue(dest, sourceProp.GetValue(source, null), null);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// Copies all properties on newly created object. Skips properties that do not exist.
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="source">The source object.</param>
|
|
|
|
|
|
|
|
public static TU DeepCopy<T, TU>(this T source)
|
|
|
|
|
|
|
|
where T : BaseItem
|
|
|
|
|
|
|
|
where TU : BaseItem, new()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var dest = new TU();
|
|
|
|
|
|
|
|
source.DeepCopy(dest);
|
|
|
|
|
|
|
|
return dest;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|