Exemplo n.º 1
0
        private static void WriteProgram(CurdayProgram program, BinaryWriter file)
        {
            // Write a null byte (I guess)
            file.Write((byte)0x00);

            // Write time slot (null-terminated string)
            file.WriteNTString(program.TimeSlot);

            // Write program flags (if there are any) (null-terminated string)
            if (!string.IsNullOrEmpty(program.ProgramFlags))
            {
                file.WriteNTString(program.ProgramFlags);
            }

            // Write program type (if there is one) (null-terminated string)
            if (!string.IsNullOrEmpty(program.ProgramType))
            {
                file.WriteNTString(program.ProgramType);
            }

            // Write movie category (is there is one) (null-terminated string)
            if (!string.IsNullOrEmpty(program.MovieCategory))
            {
                file.WriteNTString(program.MovieCategory);
            }

            // WYLO: programs don't need all their fields
            // or maybe they do (and they write one-byte NTString for empty fields)
        }
Exemplo n.º 2
0
        private static List <CurdayProgram> DeserializePrograms(JArray array)
        {
            List <CurdayProgram> result = new List <CurdayProgram>();

            foreach (var token in array)
            {
                CurdayProgram program = new CurdayProgram();

                string timeSlot = (string)token["timeSlot"];
                if (timeSlot == "0" || timeSlot == "49")
                {
                    program.TimeSlot = timeSlot;
                }
                else
                {
                    program.TimeSlot = FormatHelpers.TimeToCurdayTimeSlot(DateTime.Parse((string)token["timeSlot"]));
                }

                program.ProgramFlags  = (string)token["flags"];
                program.ProgramType   = FormatHelpers.NamedTypeToProgramType((string)token["type"]);
                program.MovieCategory = FormatHelpers.NamedCategoryToMovieCategory((string)token["movieCategory"]);
                program.ProgramName   = (string)token["name"];

                result.Add(program);
            }

            return(result);
        }
Exemplo n.º 3
0
 private static object GetSerializableObjects(CurdayProgram program)
 {
     return(new
     {
         timeSlot = FormatHelpers.CurdayTimeSlotToTime(program.TimeSlot),
         flags = program.ProgramFlags,
         type = FormatHelpers.ProgramTypeToNamedType(program.ProgramType),
         movieCategory = FormatHelpers.MovieCategoryToNamedCategory(program.MovieCategory),
         name = program.ProgramName
     });
 }
Exemplo n.º 4
0
        private static CurdayProgram ReadProgram(BinaryReader reader, out bool lastProgram)
        {
            CurdayProgram result = new CurdayProgram();

            // Skip next byte if null
            if (reader.PeekChar() == '\0')
            {
                reader.BaseStream.Position += 1;
            }

            // Read time slot (null-terminated string)
            result.TimeSlot = reader.ReadNTString();
            if (reader.PeekChar() == '[' || reader.PeekChar() == -1)
            {
                goto end;
            }

            // Read program flags (null-terminated string)
            result.ProgramFlags = reader.ReadNTString();
            if (reader.PeekChar() == '[' || reader.PeekChar() == -1)
            {
                goto end;
            }

            // Read program type (null-terminated string)
            result.ProgramType = reader.ReadNTString();
            if (reader.PeekChar() == '[' || reader.PeekChar() == -1)
            {
                goto end;
            }

            // Read movie category (null-terminated string)
            result.MovieCategory = reader.ReadNTString();
            if (reader.PeekChar() == '[' || reader.PeekChar() == -1)
            {
                goto end;
            }

            // Skip unknown values
            reader.BaseStream.Position += 2;
            if (reader.PeekChar() == '[' || reader.PeekChar() == -1)
            {
                goto end;
            }

            // Read program name (null-terminated string)
            result.ProgramName = reader.ReadNTString();

end:
            lastProgram = (reader.PeekChar() == '[' || reader.PeekChar() == -1);
            return(result);
        }