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

--- trunk/libxmltv/Core/XMLTV.cs	2013/03/10 17:41:52	118
+++ trunk/libxmltv/Core/XMLTV.cs	2013/03/10 20:19:33	126
@@ -95,6 +95,36 @@
             var list = gInstance.Programs;
             return list;
         }
+
+        public static object CreateDataSourceFromObject(object data)
+        {
+            if (data == null) { throw new ArgumentNullException("data", "cannot be null"); }
+            //BindingSource source = new BindingSource();
+
+            IDataSourceBindable binder = (data as IDataSourceBindable);
+            if (binder == null) { throw new InvalidCastException(string.Format("Cannot cast: '{0}' to '{1}'", data.GetType().Name, typeof(IDataSourceBindable).Name)); }
+            object bindable = binder.CreateBindableDataSource();
+            //source.DataSource = bindable;
+            //return source;
+            return bindable;
+        }
+
+        public static void CreateFilterFromDataSource(ref object source, params string[] args)
+        {
+            if (source == null) { throw new ArgumentNullException("source", "cannot be null"); }
+            if (args == null) { throw new ArgumentNullException("args", "cannot be null"); }
+            IDataSourceFilterable filter = (source as IDataSourceFilterable);
+            if (filter == null) { throw new InvalidCastException(string.Format("Cannot cast: '{0}' to '{1}'", source.GetType().Name, typeof(IDataSourceFilterable).Name)); }
+            filter.Filter(ref source,args);            
+        }
+        public static void CreateSorterFromDataSource(ref object source, params string[] args)
+        {
+            if (source == null) { throw new ArgumentNullException("source", "cannot be null"); }
+            if (args == null) { throw new ArgumentNullException("args", "cannot be null"); }
+            IDataSourceSortable sorter = (source as IDataSourceSortable);
+            if (sorter == null) { throw new InvalidCastException(string.Format("Cannot cast: '{0}' to '{1}'", source.GetType().Name, typeof(IDataSourceSortable).Name)); }
+            sorter.Sort(ref source, args);            
+        }
         #endregion
         #endregion
 

 

  ViewVC Help
Powered by ViewVC 1.1.22