/[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

--- trunk/libxmltv/Core/XMLTVSource.cs	2013/03/09 11:28:41	77
+++ trunk/libxmltv/Core/XMLTVSource.cs	2013/03/13 13:45:05	128
@@ -6,12 +6,20 @@
 using System.Diagnostics;
 using System.Xml.Linq;
 using System.Reflection;
+using System.IO;
 
 namespace libxmltv.Core
 {
     [Serializable]
-    internal class XMLTVSource : XMLTVBase<XMLTVRuntimeInstance>, IXMLTVSource, IDisposable//, ICloneable
+    internal class XMLTVSource : XMLTVBase<XMLTVRuntimeInstance>, IXMLTVSource, IDisposable //,IDataConverter<IXMLTVSource>, ICloneable
     {
+        //static private List<string> known_columns;
+        //static XMLTVSource()
+        //{
+        //    known_columns.Add("Source Name");
+        //    known_columns.Add("Generator Name");
+        //    known_columns.Add("Generator Url");
+        //}
        
         private Dictionary<string, string> entries = new Dictionary<string, string>();
         //internal static void CreateInstance(XMLTVRuntimeInstance xmltv)
@@ -26,19 +34,49 @@
         //    this.GeneratorName = generatorname;
         //    this.GeneratorUrl = generatorurl;
         //}
+        //public object ConvertObjectData(object source) { return this.ConvertData(source); }
+        //public IXMLTVSource ConvertData(object source)
+        //{
+        //    if (source.GetType() != typeof(XMLTVSource)) { throw new InvalidCastException(string.Format("Cannot cast: '{0}' to '{1}'", source.GetType().Name, typeof(XMLTVSource).Name)); }
+        //    //if (type != typeof(IXMLTVSource)) { throw new InvalidCastException(string.Format("Cannot cast: '{0}' to '{1}'", type.Name, typeof(IXMLTVSource).Name)); }
+        //    IXMLTVSource t = (IXMLTVSource)source;            
+        //    return t;
+        //}
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="type"></param>
+        /// <returns></returns>
+        public object CreateBindableDataSource(out Type type)
+        {
+            type = typeof(IXMLTVSource);
+            object bindable = new object();
+
+            //List<PropertyValuePair> list = new List<PropertyValuePair>();
+            //list.Add(new PropertyValuePair("Source Name", SourceName));
+            //list.Add(new PropertyValuePair("Generator Name", GeneratorName));
+            //list.Add(new PropertyValuePair("Generator Url", GeneratorUrl));
+            bindable = this;
+            return bindable;
+        }
+
         public XMLTVSource()
-            : base(null, XMLTVConstants.ROOT_ELEMENT) 
+            : base(null, XMLTVConstants.Root.RootElement) 
         {
             this.SourceName = string.Empty;
             this.GeneratorName = string.Empty;
             this.GeneratorUrl = string.Empty;
         }
-        public XMLTVSource(XMLTVRuntimeInstance instance) : base(instance, XMLTVConstants.ROOT_ELEMENT)
+        public XMLTVSource(XMLTVRuntimeInstance instance)
+            : base(instance, XMLTVConstants.Root.RootElement)
         {
+            try {
             xmltv_logger.Verbose.Debug.WriteLine("Creating Instance of XMLTVSource");
             Create();
             xmltv_logger.Verbose.Debug.WriteLine("Created Instance of XMLTVSource '{0}'", SourceName);
             UpdateInstance();
+            }
+            catch (IOException ex) { Debug.WriteLine(ex.ToString()); }
         }
 
         private void UpdateInstance()
@@ -80,7 +118,7 @@
         private void Create()
         {
             var doc = XDocument.Parse(this.GetInstance().XmlDoc);
-            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));
             //xmltv_logger.Verbose.Debug.WriteLine("\tRoot: {0}", doc.Root.Name);
             var attributes = doc.Root.Attributes().ToList();
             foreach (var attribute in attributes)
@@ -107,6 +145,6 @@
         //public object Clone()
         //{
         //    return new XMLTVSource(this.SourceName, this.GeneratorName, this.GeneratorUrl);
-        //}
+        //}   
     }
 }

 

  ViewVC Help
Powered by ViewVC 1.1.22