--- trunk/libxmltv/Core/XMLTVInstance.cs 2013/03/08 03:41:18 45 +++ trunk/libxmltv/Core/XMLTVInstance.cs 2013/03/08 05:20:12 49 @@ -3,23 +3,28 @@ using System.Linq; using System.Text; using libxmltv.Interfaces; +using System.ComponentModel; namespace libxmltv.Core { + [Serializable] internal class XMLTVRuntimeInstance : MarshalByRefObject, IXMLTVRuntimeInstance { - public XMLTVRuntimeInstance(string xmlfile) { CreateInstance(xmlfile); } - private void CreateInstance(string xmlfile) + public XMLTVRuntimeInstance(string xmlfile) : this(xmlfile, null) { } + public XMLTVRuntimeInstance(string xmlfile, EventHandler t) { CreateInstance(xmlfile,t); } + private void CreateInstance(string xmlfile, EventHandler t) { - using (Instance = new XMLTVInstance(xmlfile, this)) + CancelEvent = t; + using (XMLTVInstance instance = new XMLTVInstance(xmlfile, this)) { } } - internal XMLTVInstance Instance { get; private set; } + + //internal XMLTVInstance Instance { get; private set; } #region IXMLTV_LOADER members public System.IO.FileInfo XmlFile { get; set; } - public System.Xml.Linq.XDocument XmlDoc { get; set; } + public string XmlDoc { get; set; } #endregion #region IXMLTV_PARSER Members public IXMLTVSource Source { get; set; } @@ -27,12 +32,42 @@ public Dictionary Programs { get; set; } #endregion + internal IXMLTVSerializer Serializer + { + get + { + return new XMLTVSerializer(this); + } + } //public void Dispose() //{ // IsDisposing = true; // //throw new NotImplementedException(); //} - public bool IsDisposing { get; private set; } + //public bool IsDisposing { get; private set; } + + + 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; + } + return false; + } + } + + } internal class XMLTVInstance : IDisposable