/[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 04:01:25	46
+++ trunk/libxmltv/Core/XMLTVInstance.cs	2013/03/08 07:01:37	52
@@ -7,23 +7,25 @@
 
 namespace libxmltv.Core
 {
-    internal class XMLTVRuntimeInstance : MarshalByRefObject, IXMLTVRuntimeInstance
+    [Serializable]
+    internal class XMLTVRuntimeInstance : MarshalByRefObject, IXMLTVRuntimeInstance, ISerializer<XMLTVRuntimeInstance>
     {
-        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)
+        public XMLTVRuntimeInstance(string xmlfile) { CreateInstance(xmlfile); }
+        //public XMLTVRuntimeInstance(string xmlfile) : this(xmlfile, null) { }
+        //public XMLTVRuntimeInstance(string xmlfile, EventHandler<CancelEventArgs> t) { CreateInstance(xmlfile,t); }
+        private void CreateInstance(string xmlfile)
         {
-            CancelEvent = t;
-            using (Instance = new XMLTVInstance(xmlfile, this))
+            //CancelEvent = t;
+            using (XMLTVInstance instance = new XMLTVInstance(xmlfile, this))
             {
             }
         }
 
-        internal XMLTVInstance Instance { get; private set; }
+        //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; }
@@ -31,6 +33,16 @@
         public Dictionary<int, IXMLTVProgram> Programs { get; set; }
         #endregion   
     
+        public IXMLTVSerializer<XMLTVRuntimeInstance> Serializer
+        {
+            get 
+            {
+                ///* We have to set CancelEvent to null, before returning a new instance of the serializer otherwise all subscribers to the event will have to be marked as serializeable.
+                //   Most subscribers will be of type: System.Windows.Forms which is not marked as serializable and will fail to serialize. */
+                //if (CancelEvent != null) { CancelEvent = null; }
+                return new XMLTVSerializer<XMLTVRuntimeInstance>(this); 
+            }
+        }
         //public void Dispose()
         //{
         //    IsDisposing = true;
@@ -39,22 +51,23 @@
         //public bool IsDisposing { get; private set; }
 
 
-        private event EventHandler<CancelEventArgs> CancelEvent = null;
+        //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;
-                }
+                //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;
                 return false;
             }
         }

 

  ViewVC Help
Powered by ViewVC 1.1.22