private static List <CurdayChannel> Deserialize(JArray array)
        {
            List <CurdayChannel> result = new List <CurdayChannel>();

            foreach (var token in array)
            {
                CurdayChannel channel = new CurdayChannel();

                channel.ChannelNumber   = (string)token["number"];
                channel.SourceID        = (string)token["sourceID"];
                channel.CallLetters     = (string)token["callLetters"];
                channel.Flags1          = (ChannelFlags1)Enum.Parse(typeof(ChannelFlags1), (string)token["flags1"]);
                channel.TimeslotMask    = SixByteMask.Parse((string)token["timeslotMask"]);
                channel.BlackoutMask    = SixByteMask.Parse((string)token["blackoutMask"]);
                channel.Flags2          = (byte)token["flags2"];
                channel.BackgroundColor = Convert.ToUInt16(((string)token["backgroundColor"]).Substring(2, 4), 16);
                channel.BrushID         = Convert.ToUInt16(((string)token["brushID"]).Substring(2, 4), 16);
                channel.Flags3          = (ChannelsFlags3)Enum.Parse(typeof(ChannelsFlags3), (string)token["flags3"]);

                var programs = (JArray)token["programs"];
                channel.Programs = DeserializePrograms(programs);

                result.Add(channel);
            }

            return(result);
        }
Exemple #2
0
        public static SixByteMask Parse(string value)
        {
            SixByteMask result = new SixByteMask(0, 0, 0, 0, 0, 0);

            value = value.Trim().ToLowerInvariant();

            for (int i = 0; i < 6; i++)
            {
                char highNybble = value[(i * 2)];
                char lowNybble  = value[(i * 2) + 1];

                result.bytes[i]  = (byte)(Convert.ToInt32(highNybble.ToString(), 16) * 16);
                result.bytes[i] += (byte)(Convert.ToInt32(lowNybble.ToString(), 16));
            }

            return(result);
        }