using System; using System.Collections.Generic; using System.Linq; using System.Text; using libxmltv.Interfaces; namespace libxmltv.Core { internal abstract class XMLTVBase : IXMLTVBase where T: class, new() { public XMLTVBase(object instance) { this.Instance = instance; } private T TryConvertInstance(object instance) { try { T gInstance = (T)Convert.ChangeType(instance, typeof(T)); return gInstance; } catch (Exception ex) { xmltv_logger.Error.WriteLine(ex.ToString()); return new T(); } } private object Instance; #region IXMLTVBase members public T GetInstance() { return TryConvertInstance(Instance); } #endregion } }