/[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/XMLTVInstance.cs	2013/03/08 02:13:59	36
+++ trunk/libxmltv/Core/XMLTVInstance.cs	2013/03/08 06:15:44	50
@@ -3,27 +3,74 @@
 using System.Linq;
 using System.Text;
 using libxmltv.Interfaces;
+using System.ComponentModel;
 
 namespace libxmltv.Core
 {
+    [Serializable]
     internal class XMLTVRuntimeInstance : MarshalByRefObject, IXMLTVRuntimeInstance
     {
-        public XMLTVRuntimeInstance(string xmlfile) { CreateInstance(xmlfile); }
-        private void CreateInstance(string xmlfile) { Instance = new XMLTVInstance(xmlfile, this); }
-        internal XMLTVInstance Instance { get; private set; }
+        public XMLTVRuntimeInstance(string xmlfile) : this(xmlfile, null) { }
+        public XMLTVRuntimeInstance(string xmlfile, EventHandler<CancelEventArgs> t) { CreateInstance(xmlfile,t); }
+        private void CreateInstance(string xmlfile, EventHandler<CancelEventArgs> t)
+        {
+            CancelEvent = t;
+            using (XMLTVInstance instance = new XMLTVInstance(xmlfile, this))
+            {
+            }
+        }
+
+        //internal XMLTVInstance Instance { get; private set; }
 
         #region IXMLTV_LOADER members
         public System.IO.FileInfo XmlFile { get; set; }
-        public System.Xml.Linq.XDocument XmlDoc { get; set; }
+        public string XmlDoc { get; set; }
         #endregion
         #region IXMLTV_PARSER Members
         public IXMLTVSource Source { get; set; }
         public Dictionary<string, IXMLTVChannel> Channels { get; set; }
         public Dictionary<int, IXMLTVProgram> Programs { get; set; }
         #endregion   
+    
+        //internal IXMLTVSerializer<IXMLTVRuntimeInstance> Serializer
+        //{
+        //    get 
+        //    {
+        //        return new XMLTVSerializer<IXMLTVRuntimeInstance>(this);
+        //    }
+        //}
+        //public void Dispose()
+        //{
+        //    IsDisposing = true;
+        //    //throw new NotImplementedException();
+        //}
+        //public bool IsDisposing { get; private set; }
+
+
+        private event EventHandler<CancelEventArgs> CancelEvent = null;
+
+        public bool IsAborting
+        {
+            get
+            {
+                if (CancelEvent != null)
+                {
+                    CancelEventArgs e = new CancelEventArgs();
+                    CancelEvent.Invoke(this, e);
+                    if (e.Cancel)
+                    {
+                        xmltv_logger.Log.Verbose.Debug.WriteLine("Detected Instance abort event...");
+                    }
+                    return e.Cancel;
+                }
+                return false;
+            }
+        }
+
+
     }
 
-    internal class XMLTVInstance
+    internal class XMLTVInstance : IDisposable
     {
         public XMLTVInstance(string xmlfile, XMLTVRuntimeInstance instance) 
         { 
@@ -33,11 +80,18 @@
 
         private void CreateLoader(string xml_file, XMLTVRuntimeInstance instance)
         {
-            XMLTVLoader loader = new XMLTVLoader(xml_file, instance);
+            //XMLTVLoader loader = new XMLTVLoader(xml_file, instance);
+            XMLTVLoader.CreateInstance(xml_file, instance);
         }
         private void CreateParser(XMLTVRuntimeInstance instance)
         {
-            XMLTVParser parser = new XMLTVParser(instance);
+            //XMLTVParser parser = new XMLTVParser(instance);
+            XMLTVParser.CreateInstance(instance);
+        }
+
+        public void Dispose()
+        {
+            //throw new NotImplementedException();
         }
     }
 }

 

  ViewVC Help
Powered by ViewVC 1.1.22