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

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

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

--- trunk/libxmltv/Core/XMLTV.cs	2013/03/08 07:05:53	53
+++ trunk/libxmltv/Core/XMLTV.cs	2013/03/08 08:51:10	54
@@ -31,10 +31,19 @@
         public static IXMLTVRuntimeInstance DeSerialize(string file, out bool status) { return instance.DeSerialize(file, out status); }
         public static IXMLTVRuntimeInstance DeSerialize(Stream stream, out bool status) { return instance.DeSerialize(stream, out status); }
         #endregion
+
+        public static void DestroyInstance() { instance.DestroyInstance(); }
+
+        public static EventHandler<EventArgs> OnInstanceCreated
+        {
+            get { return instance.OnInstanceCreated; }
+            set { instance.OnInstanceCreated = value; }
+        }
     }
 
-    internal class XMLTV<INTERFACE, CLASS> : IXMLTV<INTERFACE, CLASS> where CLASS : class,INTERFACE
+    internal class XMLTV<INTERFACE, CLASS> : IDestroyInstance, IXMLTV<INTERFACE, CLASS> where CLASS : class,INTERFACE
     {
+     
         public XMLTV(params object[] args)
         {
             
@@ -88,6 +97,34 @@
         public INTERFACE DeSerialize(string file, out bool status) { return CreateSerializer().DeSerialize(file, out status); }
         public INTERFACE DeSerialize(Stream stream, out bool status) { return CreateSerializer().DeSerialize(stream, out status); }
         #endregion
+        public void DestroyInstance()
+        {
+            IDestroyInstance destoyer = (instance as IDestroyInstance);
+            if (destoyer != null)
+            {
+                destoyer.DestroyInstance();
+            }
+            else
+            {
+                xmltv_logger.Log.Error.WriteLine("Unable to call DestroyInstance() on type: '{0}'", instance.GetType().Name);
+            }            
+        }
+        private void SetOnInstanceCreated(EventHandler<EventArgs> event_instance)
+        {
+            ISetCreatedInstanceEvent setter = (instance as ISetCreatedInstanceEvent);
+            if (setter != null) { setter.SetOnInstanceCreated(event_instance); }
+        }
+        private EventHandler<EventArgs> GetOnInstanceCreated()
+        {
+            IGetCreatedInstanceEvent getter = (instance as IGetCreatedInstanceEvent);
+            if (getter != null) { return getter.GetOnInstanceCreated(); }
+            return null;
+        }
+        public EventHandler<EventArgs> OnInstanceCreated
+        {
+            get { return GetOnInstanceCreated(); }
+            set { SetOnInstanceCreated(value); }
+        }
     }
 
 }

 

  ViewVC Help
Powered by ViewVC 1.1.22