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

revision 126 by william, Sun Mar 10 20:19:33 2013 UTC revision 128 by william, Wed Mar 13 13:45:05 2013 UTC
# Line 7  using System.Collections; Line 7  using System.Collections;
7    
8  namespace libxmltv.Core  namespace libxmltv.Core
9  {  {
10      public class ChannelList : List<IXMLTVChannel>, IDataSourceBindable      public class ChannelList : List<IXMLTVChannel>, IDataSourceBindable//, IDataConverter<IChannelDefintionList>
11      {      {
12          private class ChannelDefintionList : List<ChannelDefintion>, IDataSourceSortable, IDataSourceFilterable                      private class ChannelDefintionList : List<IChannelDefintion>, IDataSourceSortable, IDataSourceFilterable, IChannelDefintionList  
13          {          {
14              public ChannelDefintionList() { }              public ChannelDefintionList() { }
15              public ChannelDefintionList(List<ChannelDefintion> collection) { collection.ForEach(s => this.Add(s)); }              public ChannelDefintionList(List<IChannelDefintion> collection) { collection.ForEach(s => this.Add(s)); }
16              #region IDataSourceSortable members              #region IDataSourceSortable members
17              public void Sort(ref object source, params string[] args)              public void Sort(ref object source, params string[] args)
18              {              {
# Line 24  namespace libxmltv.Core Line 24  namespace libxmltv.Core
24              }              }
25              #endregion              #endregion
26          }          }
27          private class ChannelDefintion          private class ChannelDefintion : IChannelDefintion
28          {          {
29              public ChannelDefintion()              public ChannelDefintion()
30              {              {
# Line 45  namespace libxmltv.Core Line 45  namespace libxmltv.Core
45          //}          //}
46          public ChannelList() { }          public ChannelList() { }
47    
48            //public object ConvertObjectData(object source) { return this.ConvertData(source); }
49            //public IChannelDefintionList ConvertData(object source)
50          public object CreateBindableDataSource()          //{
51            //    //object t = source;
52            //    if (source.GetType() != typeof(ChannelDefintionList)) { throw new InvalidCastException(string.Format("Cannot cast: '{0}' to '{1}'", source.GetType().Name, typeof(ChannelDefintionList).Name)); }
53            //    //if (type != typeof(IChannelDefintionList)) { throw new InvalidCastException(string.Format("Cannot cast: '{0}' to '{1}'", type.Name, typeof(IChannelDefintionList).Name)); }
54            //    IChannelDefintionList t = (source as IChannelDefintionList);
55            //    return t;
56            //}
57            /// <summary>
58            ///
59            /// </summary>
60            /// <param name="type"></param>
61            /// <returns></returns>
62            public object CreateBindableDataSource(out Type type)
63          {          {
64                type = typeof(IChannelDefintionList);
65              object bindable = new object();              object bindable = new object();
66              ChannelDefintionList list = new ChannelDefintionList();              ChannelDefintionList list = new ChannelDefintionList();
67                            
# Line 67  namespace libxmltv.Core Line 80  namespace libxmltv.Core
80              bindable = list;              bindable = list;
81              return bindable;              return bindable;
82          }          }
83          
84      }      }
85      public class ProgramList : List<IXMLTVProgram>, IDataSourceBindable      public class ProgramList : List<IXMLTVProgram>, IDataSourceBindable//, IDataConverter<IProgramDefinitionList>
86      {      {
87          private class ProgramDefinitionList : List<ProgramDefintion>, IDataSourceSortable, IDataSourceFilterable                    private class ProgramDefinitionList : List<IProgramDefinition>, IDataSourceSortable, IDataSourceFilterable, IProgramDefinitionList  
88          {          {
89              public ProgramDefinitionList() { }              public ProgramDefinitionList() { }
90              public ProgramDefinitionList(List<ProgramDefintion> collection) { collection.ForEach(s => this.Add(s)); }              public ProgramDefinitionList(List<IProgramDefinition> collection) { collection.ForEach(s => this.Add(s)); }
91              #region IDataSourceSortable members              #region IDataSourceSortable members
92              public void Sort(ref object source, params string[] args)              public void Sort(ref object source, params string[] args)
93              {              {
# Line 104  namespace libxmltv.Core Line 118  namespace libxmltv.Core
118              }              }
119              #endregion              #endregion
120          }          }
121          private class ProgramDefintion          private class ProgramDefintion : IProgramDefinition
122          {          {
123              public ProgramDefintion()              public ProgramDefintion()
124              {              {
# Line 127  namespace libxmltv.Core Line 141  namespace libxmltv.Core
141                        
142          }          }
143          public ProgramList() { }          public ProgramList() { }
144            //public object ConvertObjectData(object source) { return this.ConvertData(source); }
145          public object CreateBindableDataSource()          //public IProgramDefinitionList ConvertData(object source)
146            //{
147            //    if (source.GetType() != typeof(ProgramDefinitionList)) { throw new InvalidCastException(string.Format("Cannot cast: '{0}' to '{1}'", source.GetType().Name, typeof(ProgramDefinitionList).Name)); }
148            //    //if (type != typeof(IProgramDefinitionList)) { throw new InvalidCastException(string.Format("Cannot cast: '{0}' to '{1}'", type.Name, typeof(IProgramDefinitionList).Name)); }
149            //    IProgramDefinitionList t = (source as IProgramDefinitionList);
150            //    return t;
151            //}
152            /// <summary>
153            ///
154            /// </summary>
155            /// <param name="type"></param>
156            /// <returns></returns>
157            public object CreateBindableDataSource(out Type type)
158          {          {
159                type = typeof(IProgramDefinitionList);
160              object bindable = new object();              object bindable = new object();
161              ProgramDefinitionList list = new ProgramDefinitionList();              ProgramDefinitionList list = new ProgramDefinitionList();
162    
# Line 178  namespace libxmltv.Core Line 205  namespace libxmltv.Core
205      {      {
206    
207          public ExtraList() { }          public ExtraList() { }
208            /// <summary>
209          public object CreateBindableDataSource()          ///
210            /// </summary>
211            /// <param name="type"></param>
212            /// <returns></returns>
213            public object CreateBindableDataSource(out Type type)
214          {          {
215                type = typeof(object);
216              throw new NotImplementedException("Conversion of Extra MetaData to a bindable datasource has not been implemented.");              throw new NotImplementedException("Conversion of Extra MetaData to a bindable datasource has not been implemented.");
217              //object bindable = new object();              //object bindable = new object();
218              //return bindable;              //return bindable;
219          }          }
220            //public object ConvertObjectData(object source) { return source; }
221            //public object Convert(object source)
222            //{
223            //    throw new NotImplementedException("Conversion of Extra MetaData to a bindable datasource has not been implemented.");
224            //}
225      }      }
226  }  }

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

  ViewVC Help
Powered by ViewVC 1.1.22