ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/xmltv_parser/trunk/libxmltv/Core/XMLTV_LOADER.cs
Revision: 16
Committed: Thu Mar 7 09:26:43 2013 UTC (10 years, 6 months ago) by william
File size: 1923 byte(s)
Log Message:

File Contents

# Content
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_LOADER loader = new XMLTV_LOADER(xml_file);
20 return loader;
21 }
22 public static void Test(object xmltv)
23 {
24 if (!VerifyInstance<XMLTV_LOADER>(xmltv)) { return; }
25 }
26
27
28 private static bool VerifyInstance<T>(object xmltv) where T : class
29 {
30 try
31 {
32 if (xmltv == null) { return false; }
33 T t = (xmltv as T);
34 if (t == null) { throw new InvalidCastException(string.Format("Unable to cast type: {0} to {1}", xmltv.GetType().Name, typeof(T).Name)); }
35 else { return true; }
36 }
37 catch (Exception ex)
38 {
39 throw new InvalidCastException(string.Format("Unable to cast type: {0} to {1}", xmltv.GetType().Name, typeof(T).Name), ex);
40 }
41 }
42 }
43
44 internal class XMLTV_LOADER : IXMLTV_LOADER
45 {
46 private string xmlfile = string.Empty;
47 public XMLTV_LOADER(string xml_file)
48 {
49 xmlfile = xml_file;
50 LoadXml();
51 }
52 #region IXMLTV_LOADER
53 public FileInfo XmlFile { get { return new FileInfo(xmlfile); } }
54 #endregion
55
56 private void LoadXml()
57 {
58 XMLTV_LOGGER.Log.Info.WriteLine("Loading XMLTV File: {0}", XmlFile.Name);
59 XMLTV_LOGGER.Log.Warn.WriteLine("XML File Loading has not been implemented yet!");
60 }
61 }
62 }