public static void Write(Curday curday, string filePath) { // Preconditions: curday must not be null // filePath must be non-null and valid BinaryWriter file = new BinaryWriter(File.OpenWrite(filePath)); file.Dispose(); }
private static object GetSerializableObjects(Curday curday) { List <object> channelObjects = new List <object>(curday.Channels.Count); foreach (var channel in curday.Channels) { channelObjects.Add(GetSerializableObjects(channel)); } return(new { header = GetSerializableObjects(curday.Header), channels = channelObjects }); }
public static Curday Deserialize(string json) { JObject obj = JObject.Parse(json); Curday result = new Curday(); var header = obj["header"]; result.Header = Deserialize(header); var channels = (JArray)obj["channels"]; result.Channels = Deserialize(channels); return(result); }
// http://prevueguide.com/wiki/Prevue_Emulation:Curday.dat_and_Nxtday.dat internal static Curday Read(string inputFilePath) { BinaryReader reader = new BinaryReader(File.OpenRead(inputFilePath), Encoding.ASCII); Curday result = new Curday(); result.Header = ReadHeader(reader); // Read channels result.Channels = new List <CurdayChannel>(); bool lastChannel = false; while (!lastChannel) { result.Channels.Add(ReadChannel(reader, out lastChannel)); } // Set number of channels in header result.Header.NumberOfChannels = result.Channels.Count; return(result); }
public static string Serialize(Curday curday) { return(JObject.FromObject(GetSerializableObjects(curday)).ToString()); }