/[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 36 - (show annotations) (download)
Fri Mar 8 02:13:59 2013 UTC (7 years, 7 months ago) by william
File size: 2093 byte(s)
+ use a MarshalByRefObject

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

  ViewVC Help
Powered by ViewVC 1.1.22