/[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 52 by william, Fri Mar 8 07:01:37 2013 UTC revision 54 by william, Fri Mar 8 08:51:10 2013 UTC
# Line 31  namespace libxmltv.Core Line 31  namespace libxmltv.Core
31          public static IXMLTVRuntimeInstance DeSerialize(string file, out bool status) { return instance.DeSerialize(file, out status); }          public static IXMLTVRuntimeInstance DeSerialize(string file, out bool status) { return instance.DeSerialize(file, out status); }
32          public static IXMLTVRuntimeInstance DeSerialize(Stream stream, out bool status) { return instance.DeSerialize(stream, out status); }          public static IXMLTVRuntimeInstance DeSerialize(Stream stream, out bool status) { return instance.DeSerialize(stream, out status); }
33          #endregion          #endregion
34    
35            public static void DestroyInstance() { instance.DestroyInstance(); }
36    
37            public static EventHandler<EventArgs> OnInstanceCreated
38            {
39                get { return instance.OnInstanceCreated; }
40                set { instance.OnInstanceCreated = value; }
41            }
42      }      }
43    
44      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
45      {      {
46        
47          public XMLTV(params object[] args)          public XMLTV(params object[] args)
48          {          {
49              ////instance = new CLASS(xml_file, t);              
50              //instance = null;              BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
   
             //Type type = typeof(CLASS);  
             //var ctors = type.GetConstructors();  
             //foreach (var ctor in ctors)  
             //{  
             //    var ctor_params = ctor.GetParameters();  
             //    if (ctor_params.Count() == 2)  
             //    {  
             //        if (ctor_params[0].ParameterType == typeof(string))  
             //        {  
             //            if (ctor_params[1].ParameterType == typeof(EventHandler<CancelEventArgs>))  
             //            {  
             //                object o = ctor.Invoke(new object[] { xml_file, t });  
             //                instance = (CLASS)Convert.ChangeType(o, typeof(CLASS));  
             //                break;  
             //            }  
             //        }  
             //    }  
             //    else { continue; }  
             //}  
             BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Instance;  
51              CultureInfo culture = CultureInfo.CurrentCulture;              CultureInfo culture = CultureInfo.CurrentCulture;
52              try              try
53              {              {
# Line 109  namespace libxmltv.Core Line 97  namespace libxmltv.Core
97          public INTERFACE DeSerialize(string file, out bool status) { return CreateSerializer().DeSerialize(file, out status); }          public INTERFACE DeSerialize(string file, out bool status) { return CreateSerializer().DeSerialize(file, out status); }
98          public INTERFACE DeSerialize(Stream stream, out bool status) { return CreateSerializer().DeSerialize(stream, out status); }          public INTERFACE DeSerialize(Stream stream, out bool status) { return CreateSerializer().DeSerialize(stream, out status); }
99          #endregion          #endregion
100            public void DestroyInstance()
101            {
102                IDestroyInstance destoyer = (instance as IDestroyInstance);
103                if (destoyer != null)
104                {
105                    destoyer.DestroyInstance();
106                }
107                else
108                {
109                    xmltv_logger.Log.Error.WriteLine("Unable to call DestroyInstance() on type: '{0}'", instance.GetType().Name);
110                }            
111            }
112            private void SetOnInstanceCreated(EventHandler<EventArgs> event_instance)
113            {
114                ISetCreatedInstanceEvent setter = (instance as ISetCreatedInstanceEvent);
115                if (setter != null) { setter.SetOnInstanceCreated(event_instance); }
116            }
117            private EventHandler<EventArgs> GetOnInstanceCreated()
118            {
119                IGetCreatedInstanceEvent getter = (instance as IGetCreatedInstanceEvent);
120                if (getter != null) { return getter.GetOnInstanceCreated(); }
121                return null;
122            }
123            public EventHandler<EventArgs> OnInstanceCreated
124            {
125                get { return GetOnInstanceCreated(); }
126                set { SetOnInstanceCreated(value); }
127            }
128      }      }
129    
130  }  }

Legend:
Removed from v.52  
changed lines
  Added in v.54

  ViewVC Help
Powered by ViewVC 1.1.22