/[xmltv_parser]/trunk/libxmltv/Core/XMLTVLoader.cs
ViewVC logotype

Contents of /trunk/libxmltv/Core/XMLTVLoader.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 14 - (show annotations) (download)
Thu Mar 7 09:05:18 2013 UTC (7 years, 6 months ago) by william
Original Path: trunk/libxmltv/Core/XMLTV_LOADER.cs
File size: 1753 byte(s)

1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using libxmltv.Interfaces;
6 using System.IO;
7 using Enterprise.Logging;
8
9 namespace libxmltv.Core
10 {
11 /// <summary>
12 /// Main class: Creates the XMLTV Loader
13 /// </summary>
14 public static class XMLTV
15 {
16 public static object CreateLoader(string xml_file)
17 {
18 xmltv_logger.Initialize();
19 xmltv_logger.Log.Debug.WriteLine("Logged from XMLTV.CreateLoader");
20 XMLTV_LOADER loader = new XMLTV_LOADER(xml_file);
21 return loader;
22 }
23 public static void Test(object xmltv)
24 {
25 if (!VerifyInstance<XMLTV_LOADER>(xmltv)) { return; }
26 }
27
28
29 private static bool VerifyInstance<T>(object xmltv) where T : class
30 {
31 try
32 {
33 if (xmltv == null) { return false; }
34 T t = (xmltv as T);
35 if (t == null) { throw new InvalidCastException(string.Format("Unable to cast type: {0} to {1}", xmltv.GetType().Name, typeof(T).Name)); }
36 else { return true; }
37 }
38 catch (Exception ex)
39 {
40 throw new InvalidCastException(string.Format("Unable to cast type: {0} to {1}", xmltv.GetType().Name, typeof(T).Name), ex);
41 }
42 }
43 }
44
45 internal class XMLTV_LOADER : IXMLTV_LOADER
46 {
47 private string xmlfile = string.Empty;
48 public XMLTV_LOADER(string xml_file)
49 {
50 xmlfile = xml_file;
51 }
52 #region IXMLTV_LOADER
53 public FileInfo XmlFile { get { return new FileInfo(xmlfile); } }
54 #endregion
55 }
56 }

  ViewVC Help
Powered by ViewVC 1.1.22