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

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

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

revision 125 by william, Sun Mar 10 19:44:49 2013 UTC revision 126 by william, Sun Mar 10 20:19:33 2013 UTC
# Line 96  namespace libxmltv.Core Line 96  namespace libxmltv.Core
96              return list;              return list;
97          }          }
98    
99          public static BindingSource CreateBindingSourceForData(object data)          public static object CreateDataSourceFromObject(object data)
100          {          {
101              if (data == null) { throw new ArgumentNullException("data", "cannot be null"); }              if (data == null) { throw new ArgumentNullException("data", "cannot be null"); }
102              BindingSource source = new BindingSource();              //BindingSource source = new BindingSource();
103    
104              IDataSourceBindable binder = (data as IDataSourceBindable);              IDataSourceBindable binder = (data as IDataSourceBindable);
105              if (binder == null) { throw new InvalidCastException(string.Format("Cannot cast: '{0}' to '{1}'", data.GetType().Name, typeof(IDataSourceBindable).Name)); }              if (binder == null) { throw new InvalidCastException(string.Format("Cannot cast: '{0}' to '{1}'", data.GetType().Name, typeof(IDataSourceBindable).Name)); }
106              object bindable = binder.CreateBindableDataSource();              object bindable = binder.CreateBindableDataSource();
107              source.DataSource = bindable;              //source.DataSource = bindable;
108              return source;              //return source;
109                return bindable;
110          }          }
111    
112          public static BindingSource CreateFilterFromDataSource(object source, params string[] args)          public static void CreateFilterFromDataSource(ref object source, params string[] args)
113          {          {
114              if (source == null) { throw new ArgumentNullException("source", "cannot be null"); }              if (source == null) { throw new ArgumentNullException("source", "cannot be null"); }
115              if (args == null) { throw new ArgumentNullException("args", "cannot be null"); }              if (args == null) { throw new ArgumentNullException("args", "cannot be null"); }
116              IDataSourceFilterable filter = (source as IDataSourceFilterable);              IDataSourceFilterable filter = (source as IDataSourceFilterable);
117              if (filter == null) { throw new InvalidCastException(string.Format("Cannot cast: '{0}' to '{1}'", source.GetType().Name, typeof(IDataSourceFilterable).Name)); }              if (filter == null) { throw new InvalidCastException(string.Format("Cannot cast: '{0}' to '{1}'", source.GetType().Name, typeof(IDataSourceFilterable).Name)); }
118              object filtered = filter.Filter(source,args);              filter.Filter(ref source,args);            
             BindingSource bound = new BindingSource();  
             bound.DataSource = filtered;  
             return bound;  
119          }          }
120          public static BindingSource CreateSorterFromDataSource(object source, params string[] args)          public static void CreateSorterFromDataSource(ref object source, params string[] args)
121          {          {
122              if (source == null) { throw new ArgumentNullException("source", "cannot be null"); }              if (source == null) { throw new ArgumentNullException("source", "cannot be null"); }
123              if (args == null) { throw new ArgumentNullException("args", "cannot be null"); }              if (args == null) { throw new ArgumentNullException("args", "cannot be null"); }
124              IDataSourceSortable sorter = (source as IDataSourceSortable);              IDataSourceSortable sorter = (source as IDataSourceSortable);
125              if (sorter == null) { throw new InvalidCastException(string.Format("Cannot cast: '{0}' to '{1}'", source.GetType().Name, typeof(IDataSourceSortable).Name)); }              if (sorter == null) { throw new InvalidCastException(string.Format("Cannot cast: '{0}' to '{1}'", source.GetType().Name, typeof(IDataSourceSortable).Name)); }
126              object sorted = sorter.Sort(source, args);              sorter.Sort(ref source, args);            
             BindingSource bound = new BindingSource();  
             bound.DataSource = sorted;  
             return bound;  
127          }          }
128          #endregion          #endregion
129          #endregion          #endregion

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

  ViewVC Help
Powered by ViewVC 1.1.22