Beispiel #1
0
        public static T ConvertValue <T>(this object value)
        {
            var data = new LightDataTable();

            data.AddColumn("value", typeof(T), value);
            data.AddRow(new object[1] {
                value
            });
            return(data.Rows.First().TryValueAndConvert <T>(0, true));
        }
Beispiel #2
0
        public static object ConvertValue(this Type toType, object value)
        {
            var data = new LightDataTable();

            data.AddColumn("value", toType, value);
            data.AddRow(new object[1] {
                value
            });
            return(data.Rows.First()[0, true]);
        }
Beispiel #3
0
        internal static T ToType <T>(this object o) where T : class
        {
            object item;

            if (typeof(T) == typeof(IList))
            {
                return((T)(item = new LightDataTable(o).Rows.Select(x => ((IList)x.ToObject <T>())[0]).ToList()));
            }
            else
            {
                return(new LightDataTable(o).Rows.First().ToObject <T>());
            }
        }