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

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

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

revision 74 by william, Sat Mar 9 11:06:39 2013 UTC revision 78 by william, Sat Mar 9 11:36:24 2013 UTC
# Line 48  namespace libxmltv.Core Line 48  namespace libxmltv.Core
48    
49          private void init()          private void init()
50          {          {
51              this.Source = new List<IXMLTVSource>();              this.Source = new XMLTVSource();
52              this.Channels = new List<IXMLTVChannel>();              this.Channels = new List<IXMLTVChannel>();
53              this.Programs = new List<IXMLTVProgram>();              this.Programs = new List<IXMLTVProgram>();
54              this.XmlFile_Name = string.Empty;              this.XmlFile_Name = string.Empty;
# Line 69  namespace libxmltv.Core Line 69  namespace libxmltv.Core
69    
70          private string _XmlDoc;          private string _XmlDoc;
71          public string XmlDoc { get { return _XmlDoc; } set { _XmlDoc = value; } }          public string XmlDoc { get { return _XmlDoc; } set { _XmlDoc = value; } }
72          private List<IXMLTVSource> _Source;          private IXMLTVSource _Source;
73          public List<IXMLTVSource> Source { get { return _Source; } set { _Source = value; } }          public IXMLTVSource Source { get { return _Source; } set { _Source = value; } }
74          private List<IXMLTVChannel> _Channels;          private List<IXMLTVChannel> _Channels;
75          public List<IXMLTVChannel> Channels { get { return _Channels; } set { _Channels = value; } }          public List<IXMLTVChannel> Channels { get { return _Channels; } set { _Channels = value; } }
76          private List<IXMLTVProgram> _Programs;          private List<IXMLTVProgram> _Programs;
# Line 118  namespace libxmltv.Core Line 118  namespace libxmltv.Core
118              {              {
119                  throw new NullReferenceException("Failed to load from instance because the instance is null.");                  throw new NullReferenceException("Failed to load from instance because the instance is null.");
120              }              }
             CloneFromInstance(ref instance);  
121              xmltv_logger.Debug.WriteLine("Loading from instance...");              xmltv_logger.Debug.WriteLine("Loading from instance...");
122                CloneFromInstance(ref instance);            
123                xmltv_logger.Debug.WriteLine("Loaded from instance...");
124              if (this.Source != null)              if (this.Source != null)
125              {              {
126                  xmltv_logger.Info.WriteLine("Source Loaded: '{0}' Created by '{1}' - original source file: '{2}'", this.Source.FirstOrDefault().SourceName, this.Source.FirstOrDefault().GeneratorName, this.XmlFile_FullName);                  xmltv_logger.Info.WriteLine("Source Loaded: '{0}' Created by '{1}' - original source file: '{2}'", this.Source.SourceName, this.Source.GeneratorName, this.XmlFile_FullName);
127              }              }
128              else              else
129              {              {
# Line 131  namespace libxmltv.Core Line 132  namespace libxmltv.Core
132              }              }
133              if (this.Channels != null)              if (this.Channels != null)
134              {              {
135                  xmltv_logger.Info.WriteLine("Source Loaded: '{0}' Channels from source '{1}'", this.Channels.Count, this.Source.FirstOrDefault().SourceName);                  xmltv_logger.Info.WriteLine("Source Loaded: '{0}' Channels from source '{1}'", this.Channels.Count, this.Source.SourceName);
136              }              }
137              else              else
138              {              {
# Line 140  namespace libxmltv.Core Line 141  namespace libxmltv.Core
141              }              }
142              if (this.Programs != null)              if (this.Programs != null)
143              {              {
144                  xmltv_logger.Info.WriteLine("Source Loaded: '{0}' Programs from source '{1}'", this.Programs.Count, this.Source.FirstOrDefault().SourceName);                  xmltv_logger.Info.WriteLine("Source Loaded: '{0}' Programs from source '{1}'", this.Programs.Count, this.Source.SourceName);
145              }              }
146              else              else
147              {              {
148                  xmltv_logger.Error.WriteLine("Programs Property is null.");                  xmltv_logger.Error.WriteLine("Programs Property is null.");
149                  throw new NullReferenceException("Programs Property is null.");                  throw new NullReferenceException("Programs Property is null.");
150              }              }            
             xmltv_logger.Debug.WriteLine("Loaded from instance...");  
151              return instance;              return instance;
152          }          }
153          #endregion          #endregion
# Line 275  namespace libxmltv.Core Line 275  namespace libxmltv.Core
275          private void CreateParser()          private void CreateParser()
276          {          {
277              var doc = XDocument.Parse(this.GetInstance().XmlDoc);              var doc = XDocument.Parse(this.GetInstance().XmlDoc);
278              var root_element = doc.Root;              var root_element = doc.Root;            
               
279              CreateHandlerForRootNode(root_element);              CreateHandlerForRootNode(root_element);
   
280              var nodes = doc.Root.Elements().ToList();              var nodes = doc.Root.Elements().ToList();
281    
282                double total_nodes = nodes.Count;
283                double node_index = 0;
284                double progress = 0;
285              foreach(var node in nodes)              foreach(var node in nodes)
286              {              {
287                  if (!CreateHandlerForNode(node))                  if (this.GetInstance().IsAborting)
288                  {                  {
289                      xmltv_logger.Verbose.Debug.WriteLine("Unable to create handler for node: '{0}'", node.Name.ToString());                      break;
290                  }                  }
291                    if (!CreateHandlerForNode(node)) { xmltv_logger.Verbose.Debug.WriteLine("Unable to create handler for node: '{0}'", node.Name.ToString()); }
292                    node_index++;
293                    progress = 100.0 * (node_index / total_nodes);
294                    xmltv_logger.ReportProgress(this, new Enterprise.Logging.ReportProgressEventArgs((int)progress));
295                    Application.DoEvents();
296              }              }
297          }          }
298    

Legend:
Removed from v.74  
changed lines
  Added in v.78

  ViewVC Help
Powered by ViewVC 1.1.22