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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 77 by william, Sat Mar 9 11:28:41 2013 UTC revision 128 by william, Wed Mar 13 13:45:05 2013 UTC
# Line 6  using libxmltv.Interfaces; Line 6  using libxmltv.Interfaces;
6  using System.Diagnostics;  using System.Diagnostics;
7  using System.Xml.Linq;  using System.Xml.Linq;
8  using System.Reflection;  using System.Reflection;
9    using System.IO;
10    
11  namespace libxmltv.Core  namespace libxmltv.Core
12  {  {
13      [Serializable]      [Serializable]
14      internal class XMLTVSource : XMLTVBase<XMLTVRuntimeInstance>, IXMLTVSource, IDisposable//, ICloneable      internal class XMLTVSource : XMLTVBase<XMLTVRuntimeInstance>, IXMLTVSource, IDisposable //,IDataConverter<IXMLTVSource>, ICloneable
15      {      {
16            //static private List<string> known_columns;
17            //static XMLTVSource()
18            //{
19            //    known_columns.Add("Source Name");
20            //    known_columns.Add("Generator Name");
21            //    known_columns.Add("Generator Url");
22            //}
23                
24          private Dictionary<string, string> entries = new Dictionary<string, string>();          private Dictionary<string, string> entries = new Dictionary<string, string>();
25          //internal static void CreateInstance(XMLTVRuntimeInstance xmltv)          //internal static void CreateInstance(XMLTVRuntimeInstance xmltv)
# Line 26  namespace libxmltv.Core Line 34  namespace libxmltv.Core
34          //    this.GeneratorName = generatorname;          //    this.GeneratorName = generatorname;
35          //    this.GeneratorUrl = generatorurl;          //    this.GeneratorUrl = generatorurl;
36          //}          //}
37            //public object ConvertObjectData(object source) { return this.ConvertData(source); }
38            //public IXMLTVSource ConvertData(object source)
39            //{
40            //    if (source.GetType() != typeof(XMLTVSource)) { throw new InvalidCastException(string.Format("Cannot cast: '{0}' to '{1}'", source.GetType().Name, typeof(XMLTVSource).Name)); }
41            //    //if (type != typeof(IXMLTVSource)) { throw new InvalidCastException(string.Format("Cannot cast: '{0}' to '{1}'", type.Name, typeof(IXMLTVSource).Name)); }
42            //    IXMLTVSource t = (IXMLTVSource)source;            
43            //    return t;
44            //}
45            /// <summary>
46            ///
47            /// </summary>
48            /// <param name="type"></param>
49            /// <returns></returns>
50            public object CreateBindableDataSource(out Type type)
51            {
52                type = typeof(IXMLTVSource);
53                object bindable = new object();
54    
55                //List<PropertyValuePair> list = new List<PropertyValuePair>();
56                //list.Add(new PropertyValuePair("Source Name", SourceName));
57                //list.Add(new PropertyValuePair("Generator Name", GeneratorName));
58                //list.Add(new PropertyValuePair("Generator Url", GeneratorUrl));
59                bindable = this;
60                return bindable;
61            }
62    
63          public XMLTVSource()          public XMLTVSource()
64              : base(null, XMLTVConstants.ROOT_ELEMENT)              : base(null, XMLTVConstants.Root.RootElement)
65          {          {
66              this.SourceName = string.Empty;              this.SourceName = string.Empty;
67              this.GeneratorName = string.Empty;              this.GeneratorName = string.Empty;
68              this.GeneratorUrl = string.Empty;              this.GeneratorUrl = string.Empty;
69          }          }
70          public XMLTVSource(XMLTVRuntimeInstance instance) : base(instance, XMLTVConstants.ROOT_ELEMENT)          public XMLTVSource(XMLTVRuntimeInstance instance)
71                : base(instance, XMLTVConstants.Root.RootElement)
72          {          {
73                try {
74              xmltv_logger.Verbose.Debug.WriteLine("Creating Instance of XMLTVSource");              xmltv_logger.Verbose.Debug.WriteLine("Creating Instance of XMLTVSource");
75              Create();              Create();
76              xmltv_logger.Verbose.Debug.WriteLine("Created Instance of XMLTVSource '{0}'", SourceName);              xmltv_logger.Verbose.Debug.WriteLine("Created Instance of XMLTVSource '{0}'", SourceName);
77              UpdateInstance();              UpdateInstance();
78                }
79                catch (IOException ex) { Debug.WriteLine(ex.ToString()); }
80          }          }
81    
82          private void UpdateInstance()          private void UpdateInstance()
# Line 80  namespace libxmltv.Core Line 118  namespace libxmltv.Core
118          private void Create()          private void Create()
119          {          {
120              var doc = XDocument.Parse(this.GetInstance().XmlDoc);              var doc = XDocument.Parse(this.GetInstance().XmlDoc);
121              Debug.Assert(doc.Root.Name == XMLTVConstants.ROOT_ELEMENT, string.Format("Expected Root Element: '{0}' but read: '{1}'", XMLTVConstants.ROOT_ELEMENT, doc.Root.Name));              Debug.Assert(doc.Root.Name == XMLTVConstants.Root.RootElement, string.Format("Expected Root Element: '{0}' but read: '{1}'", XMLTVConstants.Root.RootElement, doc.Root.Name));
122              //xmltv_logger.Verbose.Debug.WriteLine("\tRoot: {0}", doc.Root.Name);              //xmltv_logger.Verbose.Debug.WriteLine("\tRoot: {0}", doc.Root.Name);
123              var attributes = doc.Root.Attributes().ToList();              var attributes = doc.Root.Attributes().ToList();
124              foreach (var attribute in attributes)              foreach (var attribute in attributes)
# Line 107  namespace libxmltv.Core Line 145  namespace libxmltv.Core
145          //public object Clone()          //public object Clone()
146          //{          //{
147          //    return new XMLTVSource(this.SourceName, this.GeneratorName, this.GeneratorUrl);          //    return new XMLTVSource(this.SourceName, this.GeneratorName, this.GeneratorUrl);
148          //}          //}  
149      }      }
150  }  }

Legend:
Removed from v.77  
changed lines
  Added in v.128

  ViewVC Help
Powered by ViewVC 1.1.22