/[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/09 01:46:42	71
+++ trunk/libxmltv/Core/XMLTVProgramCollection.cs	2013/03/09 09:29:40	72
@@ -9,33 +9,29 @@
 
 namespace libxmltv.Core
 {
-    internal class XMLTVProgramCollection : IDisposable
+    internal class XMLTVProgramCollection : XMLTVBase<XMLTVRuntimeInstance>, IXMLTVProgramCollection, IDisposable
     {
         private Dictionary<int, IXMLTVProgram> entries = new Dictionary<int, IXMLTVProgram>();
-        internal static void CreateInstance(XMLTVRuntimeInstance xmltv)
-        {
-            using (XMLTVProgramCollection g = new XMLTVProgramCollection(xmltv))
-            {
-                g.instance.Programs = g.Collection;
-                xmltv_logger.Info.WriteLine(g.ToString());
-            }
-        }
-        private XMLTVRuntimeInstance instance;
-        protected XMLTVProgramCollection(XMLTVRuntimeInstance xmltv)
+        //internal static void CreateInstance(XMLTVRuntimeInstance xmltv)
+        //{
+        //    using (XMLTVProgramCollection g = new XMLTVProgramCollection(xmltv)) { g.instance.Programs = g.Collection; }
+        //}
+        //private XMLTVRuntimeInstance instance;
+        protected XMLTVProgramCollection(XMLTVRuntimeInstance instance) : base(instance)
         {
             xmltv_logger.Debug.WriteLine("Creating Instance of XMLTVProgramCollection");
-            instance = xmltv;
             Create();
+            xmltv_logger.Debug.WriteLine("Created Instance of XMLTVProgramCollection");
+            xmltv_logger.Info.WriteLine(this.ToString());
         }
 
-        #region IXMLTVSource
+        #region IXMLTVProgramCollection members
         public Dictionary<int, IXMLTVProgram> Collection
         {
             get { return entries; }
         }
         #endregion
-
-        //
+      
         private DateTime ParseDate(string timeStamp)
         {
             DateTime dt = new DateTime();
@@ -48,13 +44,13 @@
         }
         private void Create()
         {
-            var doc = XDocument.Parse(instance.XmlDoc);
+            var doc = XDocument.Parse(this.GetInstance().XmlDoc);
             double program_index = 0;
             double program_count = doc.Descendants(XMLTVConstants.PROGRAM_ELEMENT).Count();
             double progress = 0;
             foreach (var c in doc.Descendants(XMLTVConstants.PROGRAM_ELEMENT))
             {
-                if (instance.IsAborting)
+                if (this.GetInstance().IsAborting)
                 {
                     xmltv_logger.Verbose.Debug.WriteLine("Detected Instance abort event...");
                     break;
@@ -77,7 +73,7 @@
                     if (!string.IsNullOrEmpty(program.Description)){ xmltv_logger.Verbose.Debug.WriteLine("\tprogram_channelid: {0}", channelid);}
                     IXMLTVChannel channel = new Channel();
                     string _channelid = channelid == null ? string.Empty : channelid.Value;
-                    if (instance.Channels.ContainsKey(_channelid)) { program.Channel = instance.Channels[_channelid]; }
+                    if (this.GetInstance().Channels.ContainsKey(_channelid)) { program.Channel = this.GetInstance().Channels[_channelid]; }
                     else { program.Channel = new Channel(); }
                     if (!string.IsNullOrEmpty(_channelid)) { xmltv_logger.Verbose.Debug.WriteLine("\tprogram_channel: {0}", program.Channel.ToString()); }
                 }

 

  ViewVC Help
Powered by ViewVC 1.1.22