ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/xmltv_parser/trunk/libxmltv/Core/XMLTV_LOADER.cs
(Generate patch)

Comparing trunk/libxmltv/Core/XMLTV_LOADER.cs (file contents):
Revision 21 by william, Thu Mar 7 10:04:58 2013 UTC vs.
Revision 22 by william, Thu Mar 7 10:20:50 2013 UTC

# Line 8 | Line 8 | using Enterprise.Logging;
8   using System.Xml.Linq;
9  
10   namespace libxmltv.Core
11 < {
12 <    /// <summary>
13 <    /// Main class: Creates the XMLTV Loader
14 <    /// </summary>
15 <    public static class XMLTV
16 <    {
17 <        public static object CreateLoader(string xml_file)
18 <        {
19 <            XMLTV_LOGGER.Initialize();
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 <
11 > {  
12      internal class XMLTV_LOADER : IXMLTV_LOADER
13      {
14          private string xmlfile = string.Empty;
15 <        public XMLTV_LOADER(string xml_file)
15 >        public XMLTV_LOADER(object xmltv)
16          {
17 <            xmlfile = xml_file;
17 >            string _xmltv;
18 >            if (!Internals.VerifyInstance<string>(xmltv, out _xmltv)) { return; }
19 >            xmlfile = _xmltv;
20              LoadXml();
21          }
22          #region IXMLTV_LOADER
23          public FileInfo XmlFile { get { return new FileInfo(xmlfile); } }
24 +        public XDocument XmlDoc { get; private set; }
25          #endregion
26  
27          private void LoadXml()
# Line 60 | Line 30 | namespace libxmltv.Core
30              //XMLTV_LOGGER.Log.Warn.WriteLine("XML File Loading has not been implemented yet!");
31              try
32              {
33 <                XDocument doc = XDocument.Load(XmlFile.FullName);
33 >                XmlDoc =  XDocument.Load(XmlFile.FullName);
34              }
35              catch (Exception ex)
36              {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines