mirror of https://github.com/ErsatzTV/ErsatzTV.git
5 changed files with 128 additions and 12 deletions
@ -0,0 +1,25 @@ |
|||||||
|
using ErsatzTV.Core.Domain; |
||||||
|
using Newtonsoft.Json; |
||||||
|
|
||||||
|
namespace ErsatzTV.Core.Extensions; |
||||||
|
|
||||||
|
public static class ProgramScheduleItemExtensions |
||||||
|
{ |
||||||
|
public static ProgramScheduleItem DeepCopy(this ProgramScheduleItem item) |
||||||
|
{ |
||||||
|
if (item == null) |
||||||
|
{ |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
var settings = new JsonSerializerSettings |
||||||
|
{ |
||||||
|
// program schedule item => graphics element => (same) program schedule item should be ignored
|
||||||
|
ReferenceLoopHandling = ReferenceLoopHandling.Ignore, |
||||||
|
NullValueHandling = NullValueHandling.Ignore |
||||||
|
}; |
||||||
|
|
||||||
|
string json = JsonConvert.SerializeObject(item, settings); |
||||||
|
return (ProgramScheduleItem)JsonConvert.DeserializeObject(json, item.GetType(), settings); |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue