//We have a very limited set of content types. This isn't a general purpose engine. Rather than having a dictionary of type->loader or something, we can do a quick hack. public static IContent Load(ContentType type, BinaryReader reader) { switch (type) { case ContentType.Font: return(FontIO.Load(reader)); case ContentType.Mesh: return(MeshIO.Load(reader)); } throw new ArgumentException($"Given content type {type} cannot be loaded; no loader is specified. Is the archive corrupted?"); }
public static void Save(IContent content, BinaryWriter writer) { switch (content.ContentType) { case ContentType.Font: FontIO.Save((FontContent)content, writer); return; case ContentType.Mesh: MeshIO.Save((MeshContent)content, writer); return; } throw new ArgumentException("Given content type cannot be saved; no archiver is specified."); }