/[xmltv_parser]/trunk/libxmltv/Core/XMLTVProgramCollection.cs
ViewVC logotype

Diff of /trunk/libxmltv/Core/XMLTVProgramCollection.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/libxmltv/Core/XMLTVProgramCollection.cs	2013/03/07 13:36:42	30
+++ trunk/libxmltv/Core/XMLTVProgramCollection.cs	2013/03/08 03:09:49	43
@@ -5,23 +5,26 @@
 using libxmltv.Interfaces;
 using System.Xml.Linq;
 using System.Globalization;
+using System.Windows.Forms;
 
 namespace libxmltv.Core
 {
     internal class XMLTVProgramCollection
     {
         private Dictionary<int, IXMLTVProgram> entries = new Dictionary<int, IXMLTVProgram>();
-        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<IXMLTV_PARSER>(xmltv, out _xmltv)) { return; }
-            XMLTV_PARSER = _xmltv;
+            //IXMLTV_PARSER _xmltv;
+            //if (!Internals.VerifyInstance<IXMLTV_PARSER>(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<int, IXMLTVProgram> Collection
         {
             get { return entries; }
@@ -41,70 +44,70 @@
         }
         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();
 
                 program.Id = index;
-                //XMLTV_LOGGER.Log.Verbose.Debug.WriteLine("program_Id: {0}", program.Id);
+                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;
+                    XMLTV_LOGGER.Log.Verbose.Debug.WriteLine("\tprogram_start: {0}", start);
+                    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;
-                    //XMLTV_LOGGER.Log.Verbose.Debug.WriteLine("\tprogram_channelid: {0}", channelid);
+                    XMLTV_LOGGER.Log.Verbose.Debug.WriteLine("\tprogram_stop: {0}", stop);
+                    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)
                     {
                         XMLTV_LOGGER.Log.Verbose.Error.WriteLine(string.Format("Unable to find Channel by id: '{0}' for this program.", channelid));
                     }
                     program.Channel = channel;
-                    //XMLTV_LOGGER.Log.Verbose.Debug.WriteLine("\tprogram_channel: {0}", program.Channel.ToString());
+                    XMLTV_LOGGER.Log.Verbose.Debug.WriteLine("\tprogram_channel: {0}", program.Channel.ToString());
                 }
                 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);
+                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);
+                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; }
-                //XMLTV_LOGGER.Log.Verbose.Debug.WriteLine("\tprogram_description: {0}", program.Description == string.Empty ? "empty" : program.Description);
+                XMLTV_LOGGER.Log.Verbose.Debug.WriteLine("\tprogram_description: {0}", program.Description == string.Empty ? "empty" : program.Description);
 
                 entries.Add(program.Id, program);
+                Application.DoEvents();
                 index++;
             }
         }
         public override string ToString()
         {
-            //return string.Format("XmlTv Source: '{0}' (Generated by: '{1}') (support: '{2}')", SourceName, GeneratorName, GeneratorUrl);
+            return string.Format("Program Count: {0}", Collection == null ? 0 : Collection.Count);
             return string.Empty;
         }
     }
-
+    [Serializable]
     internal class Program : IXMLTVProgram
     {
         public Program()

 

  ViewVC Help
Powered by ViewVC 1.1.22