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

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

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

--- trunk/libxmltv/Core/DataSourceBindable.cs	2013/03/10 20:19:33	126
+++ trunk/libxmltv/Core/DataSourceBindable.cs	2013/03/13 13:45:05	128
@@ -7,12 +7,12 @@
 
 namespace libxmltv.Core
 {
-    public class ChannelList : List<IXMLTVChannel>, IDataSourceBindable
+    public class ChannelList : List<IXMLTVChannel>, IDataSourceBindable//, IDataConverter<IChannelDefintionList>
     {
-        private class ChannelDefintionList : List<ChannelDefintion>, IDataSourceSortable, IDataSourceFilterable            
+        private class ChannelDefintionList : List<IChannelDefintion>, IDataSourceSortable, IDataSourceFilterable, IChannelDefintionList   
         {
             public ChannelDefintionList() { }
-            public ChannelDefintionList(List<ChannelDefintion> collection) { collection.ForEach(s => this.Add(s)); }
+            public ChannelDefintionList(List<IChannelDefintion> collection) { collection.ForEach(s => this.Add(s)); }
             #region IDataSourceSortable members
             public void Sort(ref object source, params string[] args)
             {
@@ -24,7 +24,7 @@
             }
             #endregion
         }
-        private class ChannelDefintion
+        private class ChannelDefintion : IChannelDefintion
         {
             public ChannelDefintion()
             {
@@ -45,10 +45,23 @@
         //}
         public ChannelList() { }
 
-
-
-        public object CreateBindableDataSource()
+        //public object ConvertObjectData(object source) { return this.ConvertData(source); }
+        //public IChannelDefintionList ConvertData(object source)
+        //{
+        //    //object t = source;
+        //    if (source.GetType() != typeof(ChannelDefintionList)) { throw new InvalidCastException(string.Format("Cannot cast: '{0}' to '{1}'", source.GetType().Name, typeof(ChannelDefintionList).Name)); }
+        //    //if (type != typeof(IChannelDefintionList)) { throw new InvalidCastException(string.Format("Cannot cast: '{0}' to '{1}'", type.Name, typeof(IChannelDefintionList).Name)); }
+        //    IChannelDefintionList t = (source as IChannelDefintionList);
+        //    return t;
+        //}
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="type"></param>
+        /// <returns></returns>
+        public object CreateBindableDataSource(out Type type)
         {
+            type = typeof(IChannelDefintionList);
             object bindable = new object();
             ChannelDefintionList list = new ChannelDefintionList();
             
@@ -67,13 +80,14 @@
             bindable = list;
             return bindable;
         }
+      
     }
-    public class ProgramList : List<IXMLTVProgram>, IDataSourceBindable
+    public class ProgramList : List<IXMLTVProgram>, IDataSourceBindable//, IDataConverter<IProgramDefinitionList>
     {
-        private class ProgramDefinitionList : List<ProgramDefintion>, IDataSourceSortable, IDataSourceFilterable           
+        private class ProgramDefinitionList : List<IProgramDefinition>, IDataSourceSortable, IDataSourceFilterable, IProgramDefinitionList  
         {
             public ProgramDefinitionList() { }
-            public ProgramDefinitionList(List<ProgramDefintion> collection) { collection.ForEach(s => this.Add(s)); }
+            public ProgramDefinitionList(List<IProgramDefinition> collection) { collection.ForEach(s => this.Add(s)); }
             #region IDataSourceSortable members
             public void Sort(ref object source, params string[] args)
             {
@@ -104,7 +118,7 @@
             }
             #endregion
         }
-        private class ProgramDefintion
+        private class ProgramDefintion : IProgramDefinition
         {
             public ProgramDefintion()
             {
@@ -127,9 +141,22 @@
           
         }
         public ProgramList() { }
-
-        public object CreateBindableDataSource()
+        //public object ConvertObjectData(object source) { return this.ConvertData(source); }
+        //public IProgramDefinitionList ConvertData(object source)
+        //{
+        //    if (source.GetType() != typeof(ProgramDefinitionList)) { throw new InvalidCastException(string.Format("Cannot cast: '{0}' to '{1}'", source.GetType().Name, typeof(ProgramDefinitionList).Name)); }
+        //    //if (type != typeof(IProgramDefinitionList)) { throw new InvalidCastException(string.Format("Cannot cast: '{0}' to '{1}'", type.Name, typeof(IProgramDefinitionList).Name)); }
+        //    IProgramDefinitionList t = (source as IProgramDefinitionList);
+        //    return t;
+        //}
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="type"></param>
+        /// <returns></returns>
+        public object CreateBindableDataSource(out Type type)
         {
+            type = typeof(IProgramDefinitionList);
             object bindable = new object();
             ProgramDefinitionList list = new ProgramDefinitionList();
 
@@ -178,12 +205,22 @@
     {
 
         public ExtraList() { }
-
-        public object CreateBindableDataSource()
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="type"></param>
+        /// <returns></returns>
+        public object CreateBindableDataSource(out Type type)
         {
+            type = typeof(object);
             throw new NotImplementedException("Conversion of Extra MetaData to a bindable datasource has not been implemented.");
             //object bindable = new object();
             //return bindable;
         }
+        //public object ConvertObjectData(object source) { return source; }
+        //public object Convert(object source)
+        //{
+        //    throw new NotImplementedException("Conversion of Extra MetaData to a bindable datasource has not been implemented.");
+        //}
     }
 }

 

  ViewVC Help
Powered by ViewVC 1.1.22