37 lines
No EOL
1.1 KiB
C#
37 lines
No EOL
1.1 KiB
C#
using System;
|
|
using Newtonsoft.Json;
|
|
using Shuttle.Api.AfterEffectsDTO.Items;
|
|
using Shuttle.Api.AfterEffectsDTO.UpdatedData;
|
|
|
|
namespace Orbit.AfterEffects.Helpers
|
|
{
|
|
public static class UpdatableDataFactory
|
|
{
|
|
public static CompItemUpdatableData CopyDataFrom(CompItem compItem)
|
|
{
|
|
return CopyData<CompItem, CompItemUpdatableData>(compItem);
|
|
}
|
|
|
|
internal static FootageItemUpdatableData CopyDataFrom(FootageItem footageItem)
|
|
{
|
|
return CopyData<FootageItem, FootageItemUpdatableData>(footageItem);
|
|
}
|
|
|
|
internal static FolderItemUpdatableData CopyDataFrom(FolderItem folderItem)
|
|
{
|
|
return CopyData<FolderItem, FolderItemUpdatableData>(folderItem);
|
|
}
|
|
|
|
private static TDataItem CopyData<TItem, TDataItem>(TItem item)
|
|
{
|
|
if (item == null)
|
|
{
|
|
throw new ArgumentNullException(nameof(item));
|
|
}
|
|
|
|
string serialized = JsonConvert.SerializeObject(item);
|
|
TDataItem data = JsonConvert.DeserializeObject<TDataItem>(serialized);
|
|
return data;
|
|
}
|
|
}
|
|
} |