--- trunk/libxmltv/Core/XMLTVInstance.cs 2013/03/08 05:20:12 49 +++ trunk/libxmltv/Core/XMLTVInstance.cs 2013/03/08 07:01:37 52 @@ -8,13 +8,14 @@ namespace libxmltv.Core { [Serializable] - internal class XMLTVRuntimeInstance : MarshalByRefObject, IXMLTVRuntimeInstance + internal class XMLTVRuntimeInstance : MarshalByRefObject, IXMLTVRuntimeInstance, ISerializer { - public XMLTVRuntimeInstance(string xmlfile) : this(xmlfile, null) { } - public XMLTVRuntimeInstance(string xmlfile, EventHandler t) { CreateInstance(xmlfile,t); } - private void CreateInstance(string xmlfile, EventHandler t) + public XMLTVRuntimeInstance(string xmlfile) { CreateInstance(xmlfile); } + //public XMLTVRuntimeInstance(string xmlfile) : this(xmlfile, null) { } + //public XMLTVRuntimeInstance(string xmlfile, EventHandler t) { CreateInstance(xmlfile,t); } + private void CreateInstance(string xmlfile) { - CancelEvent = t; + //CancelEvent = t; using (XMLTVInstance instance = new XMLTVInstance(xmlfile, this)) { } @@ -32,11 +33,14 @@ public Dictionary Programs { get; set; } #endregion - internal IXMLTVSerializer Serializer + public IXMLTVSerializer Serializer { get { - return new XMLTVSerializer(this); + ///* 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(this); } } //public void Dispose() @@ -47,22 +51,23 @@ //public bool IsDisposing { get; private set; } - private event EventHandler CancelEvent = null; + //private event EventHandler 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; } }