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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 25 - (show annotations) (download)
Thu Mar 7 11:36:00 2013 UTC (7 years, 7 months ago) by william
File size: 1994 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.Diagnostics;
7
8 namespace libxmltv.Core
9 {
10 internal class XMLTVSource : IXMLTVSource
11 {
12 private Dictionary<string, string> entries = new Dictionary<string, string>();
13 public XMLTVSource(object xmltv)
14 {
15 XMLTV_LOGGER.Log.Verbose.Debug.WriteLine("Creating Instance of XMLTVSource");
16 IXMLTV_PARSER _xmltv;
17 if (!Internals.VerifyInstance<IXMLTV_PARSER>(xmltv, out _xmltv)) { return; }
18 XMLTV_PARSER = _xmltv;
19 Create();
20 }
21
22 #region IXMLTVSource
23 private IXMLTV_PARSER XMLTV_PARSER { get; set; }
24 public string SourceName { get { return entries[XMLTV_CONSTANTS.Source.SourceName]; } }
25 public string GeneratorName { get { return entries[XMLTV_CONSTANTS.Source.GeneratorName]; } }
26 public string GeneratorUrl { get { return entries[XMLTV_CONSTANTS.Source.GeneratorUrl]; } }
27 #endregion
28
29 private void Create()
30 {
31 var doc = XMLTV_PARSER.XMLTV_LOADER.XmlDoc;
32 Debug.Assert(doc.Root.Name == XMLTV_CONSTANTS.ROOT_ELEMENT, string.Format("Expected Root Element: '{0}' but read: '{1}'", XMLTV_CONSTANTS.ROOT_ELEMENT, doc.Root.Name));
33 XMLTV_LOGGER.Log.Verbose.Debug.WriteLine("\tRoot: {0}", doc.Root.Name);
34 var attributes = doc.Root.Attributes().ToList();
35 foreach (var attribute in attributes)
36 {
37 //XMLTV_LOGGER.Log.Verbose.Debug.WriteLine("\t{0}: {1}", attribute.Name, attribute.Value);
38 entries.Add(attribute.Name.ToString(), attribute.Value);
39 }
40 }
41 public override string ToString()
42 {
43 return string.Format("XmlTv Source: '{0}' (Generated by: '{1}') (support: '{2}')", SourceName, GeneratorName, GeneratorUrl);
44 }
45 }
46 }

  ViewVC Help
Powered by ViewVC 1.1.22