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

revision 72 by william, Sat Mar 9 09:29:40 2013 UTC revision 117 by william, Sun Mar 10 17:10:47 2013 UTC
# Line 25  namespace libxmltv.Core Line 25  namespace libxmltv.Core
25          }          }
26    
27          static IXMLTV<IXMLTVRuntimeInstance, XMLTVRuntimeInstance> instance;          static IXMLTV<IXMLTVRuntimeInstance, XMLTVRuntimeInstance> instance;
28          public static IXMLTVRuntimeInstance GetInstance() { return instance.GetInstance(); }          internal static IXMLTVRuntimeInstance GetInstance() { return instance.GetInstance(); }
29          public static void CreateInstance(params object[] args) { instance = new XMLTV<IXMLTVRuntimeInstance, XMLTVRuntimeInstance>(args); }                  internal static void CreateInstance(params object[] args) { instance = new XMLTV<IXMLTVRuntimeInstance, XMLTVRuntimeInstance>(args); }
30    
31          public static void CreateFromInstance(object raw_instance, EventHandler<EventArgs> handler)          internal static void CreateFromInstance(object raw_instance, EventHandler<EventArgs> handler)
32          {          {
33              instance = new XMLTV<IXMLTVRuntimeInstance, XMLTVRuntimeInstance>(raw_instance,handler);              instance = new XMLTV<IXMLTVRuntimeInstance, XMLTVRuntimeInstance>(raw_instance,handler);
34              if (OnInstanceCreated != null)              if (OnInstanceCreated != null)
# Line 38  namespace libxmltv.Core Line 38  namespace libxmltv.Core
38          }          }
39    
40          #region IXMLTVSerializer<IXMLTVRuntimeInstance> members          #region IXMLTVSerializer<IXMLTVRuntimeInstance> members
41          public static bool Serialize(string file) { return instance.Serialize(file); }          internal static bool Serialize(string file) { return instance.Serialize(file); }
42          public static bool Serialize(Stream stream) { return instance.Serialize(stream); }          internal static bool Serialize(Stream stream) { return instance.Serialize(stream); }
43          public static IXMLTVRuntimeInstance DeSerialize(string file, out bool status) { return instance.DeSerialize(file, out status); }          internal static bool DeSerialize(string file)
44          public static IXMLTVRuntimeInstance DeSerialize(Stream stream, out bool status) { return instance.DeSerialize(stream, out status); }          {
45                bool status;
46                var gInstance = instance.DeSerialize(file, out status);
47                ISetInstance<IXMLTVRuntimeInstance> setter = (instance as ISetInstance<IXMLTVRuntimeInstance>);
48                if (setter != null) { setter.SetInstance(gInstance); }
49                return status;
50            }
51            internal static bool DeSerialize(Stream stream)
52            {
53                bool status;
54                var gInstance = instance.DeSerialize(stream, out status);
55                ISetInstance<IXMLTVRuntimeInstance> setter = (instance as ISetInstance<IXMLTVRuntimeInstance>);
56                if (setter != null) { setter.SetInstance(gInstance); }
57                return status;
58            }
59          #endregion          #endregion
60            internal static void DestroyInstance() { instance.DestroyInstance(); }
61    
62          public static void DestroyInstance() { instance.DestroyInstance(); }                  internal static EventHandler<EventArgs> OnInstanceCreated
   
         public static EventHandler<EventArgs> OnInstanceCreated  
63          {          {
64              get { return instance.OnInstanceCreated; }              get { return instance.OnInstanceCreated; }
65              set { instance.OnInstanceCreated = value; }              set { instance.OnInstanceCreated = value; }
66          }          }
67    
68            #region public members
69            public static bool Save(string file) { return Serialize(file); }
70            public static bool Load(string file) { return DeSerialize(file); }
71            public static void Create(params object[] args) { CreateInstance(args); }
72            public static void Destroy() { DestroyInstance(); }
73            #endregion
74      }      }
75    
76      internal class XMLTV<INTERFACE, CLASS> : IDestroyInstance, IXMLTV<INTERFACE, CLASS> where CLASS : class,INTERFACE,new()      internal class XMLTV<INTERFACE, CLASS> : IDestroyInstance, IXMLTV<INTERFACE, CLASS> where CLASS : class,INTERFACE,new()
# Line 117  namespace libxmltv.Core Line 137  namespace libxmltv.Core
137          {          {
138              return (INTERFACE)instance;              return (INTERFACE)instance;
139          }          }
140            public void SetInstance(INTERFACE gInstance)
141            {
142                this.instance = gInstance as CLASS;
143            }
144          #endregion          #endregion
145    
146          #region IXMLTVSerializer<INTERFACE> members          #region IXMLTVSerializer<INTERFACE> members

Legend:
Removed from v.72  
changed lines
  Added in v.117

  ViewVC Help
Powered by ViewVC 1.1.22