--- trunk/libxmltv/Core/XMLTVProgramCollection.cs 2013/03/07 13:46:39 31 +++ trunk/libxmltv/Core/XMLTVProgramCollection.cs 2013/03/08 02:13:59 36 @@ -11,17 +11,19 @@ internal class XMLTVProgramCollection { private Dictionary entries = new Dictionary(); - public XMLTVProgramCollection(object xmltv) + private XMLTVRuntimeInstance instance; + public XMLTVProgramCollection(XMLTVRuntimeInstance xmltv) { XMLTV_LOGGER.Log.Verbose.Debug.WriteLine("Creating Instance of XMLTVProgramCollection"); - IXMLTV_PARSER _xmltv; - if (!Internals.VerifyInstance(xmltv, out _xmltv)) { return; } - XMLTV_PARSER = _xmltv; + //IXMLTV_PARSER _xmltv; + //if (!Internals.VerifyInstance(xmltv, out _xmltv)) { return; } + //XMLTV_PARSER = _xmltv; + instance = xmltv; Create(); } #region IXMLTVSource - private IXMLTV_PARSER XMLTV_PARSER { get; set; } + //private IXMLTV_PARSER XMLTV_PARSER { get; set; } public Dictionary Collection { get { return entries; } @@ -41,9 +43,9 @@ } private void Create() { - var doc = XMLTV_PARSER.XMLTV_LOADER.XmlDoc; + var doc = instance.XmlDoc; int index = 0; - foreach (var c in doc.Descendants(XMLTV_CONSTANTS.PROGRAM_ELEMENT)) + foreach (var c in doc.Descendants(XMLTVConstants.PROGRAM_ELEMENT)) { Program program = new Program(); @@ -51,19 +53,18 @@ //XMLTV_LOGGER.Log.Verbose.Debug.WriteLine("program_Id: {0}", program.Id); if (c.HasAttributes) { - var start = c.Attribute(XMLTV_CONSTANTS.Programs.ProgramStart).Value; + var start = c.Attribute(XMLTVConstants.Programs.ProgramStart).Value; program.Start = ParseDate(start); //XMLTV_LOGGER.Log.Verbose.Debug.WriteLine("\tprogram_start: {0}", start); - var stop = c.Attribute(XMLTV_CONSTANTS.Programs.ProgramStop).Value; + var stop = c.Attribute(XMLTVConstants.Programs.ProgramStop).Value; program.Stop = ParseDate(stop); //XMLTV_LOGGER.Log.Verbose.Debug.WriteLine("\tprogram_stop: {0}", stop); - var channelid = c.Attribute(XMLTV_CONSTANTS.Programs.ProgramChannelId).Value; + var channelid = c.Attribute(XMLTVConstants.Programs.ProgramChannelId).Value; //XMLTV_LOGGER.Log.Verbose.Debug.WriteLine("\tprogram_channelid: {0}", channelid); IXMLTVChannel channel = new Channel(); try { - channel = XMLTV_PARSER.Channels[channelid]; - + channel = instance.Channels[channelid]; } catch (KeyNotFoundException) { @@ -74,21 +75,21 @@ } try { - var title = c.Descendants(XMLTV_CONSTANTS.Programs.ProgramTitle).FirstOrDefault().Value; + var title = c.Descendants(XMLTVConstants.Programs.ProgramTitle).FirstOrDefault().Value; program.Title = title; } catch (Exception) { program.Title = string.Empty; } //XMLTV_LOGGER.Log.Verbose.Debug.WriteLine("\tprogram_title: {0}", program.Title == string.Empty ? "empty" : program.Title); try { - var subtitle = c.Descendants(XMLTV_CONSTANTS.Programs.ProgramSubTitle).FirstOrDefault().Value; + var subtitle = c.Descendants(XMLTVConstants.Programs.ProgramSubTitle).FirstOrDefault().Value; program.SubTitle = subtitle; } catch (Exception) { program.SubTitle = string.Empty; } //XMLTV_LOGGER.Log.Verbose.Debug.WriteLine("\tprogram_subtitle: {0}", program.SubTitle == string.Empty ? "empty" : program.SubTitle); try { - var description = c.Descendants(XMLTV_CONSTANTS.Programs.ProgramDescription).FirstOrDefault().Value; + var description = c.Descendants(XMLTVConstants.Programs.ProgramDescription).FirstOrDefault().Value; program.Description = description; } catch (Exception) { program.Description = string.Empty; }