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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 31 - (hide annotations) (download)
Thu Mar 7 13:46:39 2013 UTC (7 years, 7 months ago) by william
File size: 2014 byte(s)
+ add support to save and read serialized Program/Channel data

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

  ViewVC Help
Powered by ViewVC 1.1.22