/[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

--- trunk/libxmltv/Core/XMLTVRuntimeInstance.cs	2013/03/09 11:06:39	74
+++ trunk/libxmltv/Core/XMLTVRuntimeInstance.cs	2013/03/09 11:23:09	76
@@ -118,8 +118,9 @@
             {
                 throw new NullReferenceException("Failed to load from instance because the instance is null.");
             }
-            CloneFromInstance(ref instance);
             xmltv_logger.Debug.WriteLine("Loading from instance...");
+            CloneFromInstance(ref instance);            
+            xmltv_logger.Debug.WriteLine("Loaded from instance...");
             if (this.Source != null)
             {
                 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);
@@ -146,8 +147,7 @@
             {
                 xmltv_logger.Error.WriteLine("Programs Property is null.");
                 throw new NullReferenceException("Programs Property is null.");
-            }
-            xmltv_logger.Debug.WriteLine("Loaded from instance...");
+            }            
             return instance;
         }
         #endregion
@@ -275,17 +275,20 @@
         private void CreateParser()
         {
             var doc = XDocument.Parse(this.GetInstance().XmlDoc);
-            var root_element = doc.Root;
-            
+            var root_element = doc.Root;            
             CreateHandlerForRootNode(root_element);
-
             var nodes = doc.Root.Elements().ToList();
+
+            double total_nodes = nodes.Count;
+            double node_index = 0;
+            double progress = 0;
             foreach(var node in nodes)
             {
-                if (!CreateHandlerForNode(node))
-                {
-                    xmltv_logger.Verbose.Debug.WriteLine("Unable to create handler for node: '{0}'", node.Name.ToString());
-                }
+                if (!CreateHandlerForNode(node)) { xmltv_logger.Verbose.Debug.WriteLine("Unable to create handler for node: '{0}'", node.Name.ToString()); }
+                node_index++;
+                progress = 100.0 * (node_index / total_nodes);
+                xmltv_logger.ReportProgress(this, new Enterprise.Logging.ReportProgressEventArgs((int)progress));
+                Application.DoEvents();
             }
         }
 

 

  ViewVC Help
Powered by ViewVC 1.1.22