/[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 72 - (hide annotations) (download)
Sat Mar 9 09:29:40 2013 UTC (7 years, 8 months ago) by william
File size: 3158 byte(s)

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 william 49 using System.Xml.Linq;
8 william 25
9     namespace libxmltv.Core
10     {
11 william 31 [Serializable]
12 william 72 internal class XMLTVSource : XMLTVBase<XMLTVRuntimeInstance>, IXMLTVSource, IDisposable//, ICloneable
13 william 25 {
14 william 72
15 william 25 private Dictionary<string, string> entries = new Dictionary<string, string>();
16 william 72 //internal static void CreateInstance(XMLTVRuntimeInstance xmltv)
17     //{
18     // using (XMLTVSource g = new XMLTVSource(xmltv)) { g.instance.Source = (IXMLTVSource)g.Clone(); }
19     //}
20 william 44
21 william 72 //private XMLTVRuntimeInstance instance;
22     //protected XMLTVSource(string sourcename, string generatorname, string generatorurl)
23     //{
24     // this.SourceName = sourcename;
25     // this.GeneratorName = generatorname;
26     // this.GeneratorUrl = generatorurl;
27     //}
28     public XMLTVSource() : base(null)
29 william 25 {
30 william 72 this.SourceName = string.Empty;
31     this.GeneratorName = string.Empty;
32     this.GeneratorUrl = string.Empty;
33 william 44 }
34 william 72 public XMLTVSource(XMLTVRuntimeInstance instance) : base(instance)
35 william 44 {
36 william 69 xmltv_logger.Debug.WriteLine("Creating Instance of XMLTVSource");
37 william 25 Create();
38 william 72 xmltv_logger.Debug.WriteLine("Created Instance of XMLTVSource '{0}'", SourceName);
39 william 25 }
40    
41     #region IXMLTVSource
42 william 36 //private IXMLTV_PARSER XMLTV_PARSER { get; set; }
43 william 44 public string SourceName { get; private set; }
44     public string GeneratorName { get; private set; }
45     public string GeneratorUrl { get; private set; }
46 william 25 #endregion
47    
48     private void Create()
49     {
50 william 72 var doc = XDocument.Parse(this.GetInstance().XmlDoc);
51 william 36 Debug.Assert(doc.Root.Name == XMLTVConstants.ROOT_ELEMENT, string.Format("Expected Root Element: '{0}' but read: '{1}'", XMLTVConstants.ROOT_ELEMENT, doc.Root.Name));
52 william 55 //xmltv_logger.Verbose.Debug.WriteLine("\tRoot: {0}", doc.Root.Name);
53 william 25 var attributes = doc.Root.Attributes().ToList();
54     foreach (var attribute in attributes)
55     {
56 william 59 xmltv_logger.Verbose.Debug.WriteLine("\t{0}: {1}", attribute.Name, attribute.Value);
57 william 25 entries.Add(attribute.Name.ToString(), attribute.Value);
58     }
59 william 44
60     SourceName = entries[XMLTVConstants.Source.SourceName];
61     GeneratorName = entries[XMLTVConstants.Source.GeneratorName];
62     GeneratorUrl = entries[XMLTVConstants.Source.GeneratorUrl];
63    
64 william 25 }
65     public override string ToString()
66     {
67     return string.Format("XmlTv Source: '{0}' (Generated by: '{1}') (support: '{2}')", SourceName, GeneratorName, GeneratorUrl);
68     }
69 william 44
70     public void Dispose()
71     {
72     //throw new NotImplementedException();
73     }
74    
75 william 72 //public object Clone()
76     //{
77     // return new XMLTVSource(this.SourceName, this.GeneratorName, this.GeneratorUrl);
78     //}
79 william 25 }
80     }

  ViewVC Help
Powered by ViewVC 1.1.22