/[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/09 09:29:40	72
+++ trunk/libxmltv/Core/XMLTV.cs	2013/03/10 17:10:47	117
@@ -25,10 +25,10 @@
         }
 
         static IXMLTV<IXMLTVRuntimeInstance, XMLTVRuntimeInstance> instance;
-        public static IXMLTVRuntimeInstance GetInstance() { return instance.GetInstance(); }
-        public static void CreateInstance(params object[] args) { instance = new XMLTV<IXMLTVRuntimeInstance, XMLTVRuntimeInstance>(args); }        
+        internal static IXMLTVRuntimeInstance GetInstance() { return instance.GetInstance(); }
+        internal static void CreateInstance(params object[] args) { instance = new XMLTV<IXMLTVRuntimeInstance, XMLTVRuntimeInstance>(args); }
 
-        public static void CreateFromInstance(object raw_instance, EventHandler<EventArgs> handler) 
+        internal static void CreateFromInstance(object raw_instance, EventHandler<EventArgs> handler) 
         { 
             instance = new XMLTV<IXMLTVRuntimeInstance, XMLTVRuntimeInstance>(raw_instance,handler);
             if (OnInstanceCreated != null)
@@ -38,19 +38,39 @@
         }
 
         #region IXMLTVSerializer<IXMLTVRuntimeInstance> members
-        public static bool Serialize(string file) { return instance.Serialize(file); }
-        public static bool Serialize(Stream stream) { return instance.Serialize(stream); }
-        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); }
+        internal static bool Serialize(string file) { return instance.Serialize(file); }
+        internal static bool Serialize(Stream stream) { return instance.Serialize(stream); }
+        internal static bool DeSerialize(string file)
+        {
+            bool status; 
+            var gInstance = instance.DeSerialize(file, out status);
+            ISetInstance<IXMLTVRuntimeInstance> setter = (instance as ISetInstance<IXMLTVRuntimeInstance>);
+            if (setter != null) { setter.SetInstance(gInstance); }
+            return status;
+        }
+        internal static bool DeSerialize(Stream stream)
+        {
+            bool status;
+            var gInstance = instance.DeSerialize(stream, out status);
+            ISetInstance<IXMLTVRuntimeInstance> setter = (instance as ISetInstance<IXMLTVRuntimeInstance>);
+            if (setter != null) { setter.SetInstance(gInstance); }
+            return status;
+        }
         #endregion
+        internal static void DestroyInstance() { instance.DestroyInstance(); }
 
-        public static void DestroyInstance() { instance.DestroyInstance(); }        
-
-        public static EventHandler<EventArgs> OnInstanceCreated
+        internal static EventHandler<EventArgs> OnInstanceCreated
         {
             get { return instance.OnInstanceCreated; }
             set { instance.OnInstanceCreated = value; }
         }
+
+        #region public members
+        public static bool Save(string file) { return Serialize(file); }
+        public static bool Load(string file) { return DeSerialize(file); }
+        public static void Create(params object[] args) { CreateInstance(args); }
+        public static void Destroy() { DestroyInstance(); }
+        #endregion
     }
 
     internal class XMLTV<INTERFACE, CLASS> : IDestroyInstance, IXMLTV<INTERFACE, CLASS> where CLASS : class,INTERFACE,new()
@@ -117,6 +137,10 @@
         {
             return (INTERFACE)instance;
         }
+        public void SetInstance(INTERFACE gInstance)
+        {
+            this.instance = gInstance as CLASS;
+        }
         #endregion
 
         #region IXMLTVSerializer<INTERFACE> members

 

  ViewVC Help
Powered by ViewVC 1.1.22