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 |
using System.Xml.Linq; |
9 |
|
10 |
namespace libxmltv.Core |
11 |
{ |
12 |
internal class XMLTVLoader : IDisposable |
13 |
{ |
14 |
private string xmlfile = string.Empty; |
15 |
internal static void CreateInstance(string xml_file, XMLTVRuntimeInstance xmltv) |
16 |
{ |
17 |
using (XMLTVLoader g = new XMLTVLoader(xml_file, xmltv)) { } |
18 |
} |
19 |
private XMLTVRuntimeInstance instance; |
20 |
protected XMLTVLoader(string xml_file, XMLTVRuntimeInstance xmltv) |
21 |
{ |
22 |
XMLTV_LOGGER.Log.Verbose.Debug.WriteLine("Creating Instance of XMLTVLoader"); |
23 |
//string _xmltv; |
24 |
//if (!Internals.VerifyInstance<string>(xmltv, out _xmltv)) { return; } |
25 |
//xmlfile = _xmltv; |
26 |
//LoadXml(); |
27 |
instance = xmltv; |
28 |
instance.XmlFile = new FileInfo(xml_file); |
29 |
LoadXml(); |
30 |
} |
31 |
//#region IXMLTV_LOADER |
32 |
//public FileInfo XmlFile { get { return new FileInfo(xmlfile); } } |
33 |
//public XDocument XmlDoc { get; private set; } |
34 |
//#endregion |
35 |
|
36 |
private void LoadXml() |
37 |
{ |
38 |
XMLTV_LOGGER.Log.Info.WriteLine("Loading XMLTV File: {0}", instance.XmlFile.Name); |
39 |
//XMLTV_LOGGER.Log.Warn.WriteLine("XML File Loading has not been implemented yet!"); |
40 |
try |
41 |
{ |
42 |
instance.XmlDoc = XDocument.Load(instance.XmlFile.FullName); |
43 |
} |
44 |
catch (Exception ex) |
45 |
{ |
46 |
XMLTV_LOGGER.Log.Error.WriteLine("Failed to load XMLTV File: {0}", instance.XmlFile.Name); |
47 |
XMLTV_LOGGER.Log.Error.WriteLine(ex.GetBaseException().ToString()); |
48 |
} |
49 |
} |
50 |
|
51 |
public void Dispose() |
52 |
{ |
53 |
//throw new NotImplementedException(); |
54 |
} |
55 |
} |
56 |
} |