using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using libxmltv.Interfaces;
using System.IO;
using Enterprise.Logging;
namespace libxmltv.Core
{
///
/// Main class: Creates the XMLTV Loader
///
public static class XMLTV
{
public static object CreateLoader(string xml_file)
{
xmltv_logger.Initialize();
xmltv_logger.Log.Debug.WriteLine("Logged from XMLTV.CreateLoader");
XMLTV_LOADER loader = new XMLTV_LOADER(xml_file);
return loader;
}
public static void Test(object xmltv)
{
if (!VerifyInstance(xmltv)) { return; }
}
private static bool VerifyInstance(object xmltv) where T : class
{
try
{
if (xmltv == null) { return false; }
T t = (xmltv as T);
if (t == null) { throw new InvalidCastException(string.Format("Unable to cast type: {0} to {1}", xmltv.GetType().Name, typeof(T).Name)); }
else { return true; }
}
catch (Exception ex)
{
throw new InvalidCastException(string.Format("Unable to cast type: {0} to {1}", xmltv.GetType().Name, typeof(T).Name), ex);
}
}
}
internal class XMLTV_LOADER : IXMLTV_LOADER
{
private string xmlfile = string.Empty;
public XMLTV_LOADER(string xml_file)
{
xmlfile = xml_file;
}
#region IXMLTV_LOADER
public FileInfo XmlFile { get { return new FileInfo(xmlfile); } }
#endregion
}
}