using System;
using System.Collections.Generic;
using System.Linq;

public interface ISerializableContainer
{
    public abstract ObjectContainerSerializable Serialize();
}

[System.Serializable]
public class ObjectContainerSerializable
{
    public string Filename;
    public string GUID;
    public List<FrameContent> Frames;

    public ObjectContainerSerializable() { }

    public ObjectContainerSerializable(ObjectContainer containerBase)
    {
        this.Filename = containerBase.name;
        this.GUID = containerBase.GUID;
        this.Frames = containerBase.Frames.Select(frame => new FrameContent(frame)).ToList();
    }

    public ObjectContainerSerializable(ObjectContainerSerializable source)
    {
        this.Filename = source.Filename;
        this.GUID = source.GUID;
        this.Frames = source.Frames.Select(frame => new FrameContent(frame)).ToList();
    }

    /// <summary>
    /// Call type's constructor with container as parameter
    /// </summary>
    /// <param name="type">Must derive from ObjectContainer</param>
    /// <param name="container">Type must accept it as the only constructor parameter</param>
    /// <returns></returns>
    public static ObjectContainerSerializable Serialize(Type type, ObjectContainer container)
    {
        return Activator.CreateInstance(type, new object[] { container }) as ObjectContainerSerializable;
    }
}