--- trunk/libxmltv/Core/XMLTV.cs 2013/03/10 20:19:33 126
+++ trunk/libxmltv/Core/XMLTV.cs 2013/03/13 15:16:59 131
@@ -8,6 +8,7 @@
using System.Reflection;
using System.Globalization;
using System.Windows.Forms;
+using Enterprise.Logging;
namespace libxmltv.Core
{
@@ -77,53 +78,90 @@
#endregion
#region Get Data
+ ///
+ /// Gets the source of the XMLTV Data :
+ ///
+ /// returns an instance of the xmltv data source :
public static IXMLTVSource GetSource()
{
var gInstance = GetInstance();
var list = gInstance.Source;
return list;
}
+ ///
+ /// Gets the collection of XMLTV Channels : List of
+ ///
+ /// returns an instance of the xmltv channels : as a list of:
public static List GetChannels()
{
var gInstance = GetInstance();
var list = gInstance.Channels;
return list;
}
+ ///
+ /// Gets the collection of XMLTV Programs : List of
+ ///
+ /// returns an instance of the xmltv channels : as a list of:
public static List GetPrograms()
{
var gInstance = GetInstance();
var list = gInstance.Programs;
return list;
}
-
- public static object CreateDataSourceFromObject(object data)
+ ///
+ /// Creates a binding source for a bindable control
+ ///
+ /// The object data to create a binding source from
+ /// Represents the underlying type of the created binding source data
+ /// Returns an object representing the created binding source
+ public static object CreateBindingSourceFromData(object data, out Type type)
{
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();
+ object bindable = binder.CreateBindableDataSource(out type);
//source.DataSource = bindable;
//return source;
return bindable;
}
+ private static object ConvertSourceType(Type source_type, object source)
+ {
+ //try
+ //{
+ // IDataConverter converter = (source as IDataConverter);
+ // if (converter == null) { throw new InvalidCastException(string.Format("Cannot cast: '{0}' to '{1}'", source.GetType().Name, typeof(IDataConverter).Name)); }
+ // object t = converter.ConvertObjectData(source);
+ // if (t != null) { source = t; }
+ // return t;
+ //}
+ //catch (Exception ex) { gLog.Verbose.Error.WriteLine(ex.ToString()); return null; }
+ return source;
+ }
+
public static void CreateFilterFromDataSource(ref object source, params string[] args)
{
if (source == null) { throw new ArgumentNullException("source", "cannot be null"); }
+ object t = ConvertSourceType(source.GetType(), source);
+ if (t == null) { throw new ArgumentException("source_type", string.Format("Cannot cast: '{0}' to '{1}'", source.GetType().Name, source.GetType().Name)); }
if (args == null) { throw new ArgumentNullException("args", "cannot be null"); }
+ source = t;
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);
+ filter.Filter(ref source, args);
}
- public static void CreateSorterFromDataSource(ref object source, params string[] args)
+ public static void CreateSorterFromDataSource(ref object source, bool descending, params string[] args)
{
if (source == null) { throw new ArgumentNullException("source", "cannot be null"); }
+ object t = ConvertSourceType(source.GetType(), source);
+ if (t == null) { throw new ArgumentException("source_type", string.Format("Cannot cast: '{0}' to '{1}'", source.GetType().Name, source.GetType().Name)); }
if (args == null) { throw new ArgumentNullException("args", "cannot be null"); }
+ source = t;
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);
+ sorter.Sort(ref source, descending, args);
}
#endregion
#endregion