Beispiel #1
0
        /// <summary>
        /// Convert table to target enumerable
        /// </summary>
        /// <param name="table">Table</param>
        /// <param name="type">Target type</param>
        /// <returns>Target enumerable</returns>
        public static IEnumerable <object> Convert(this Table table, Type type)
        {
            var mapper = new TableMapper(type);

            mapper.Extract();
            return(Convert(table, mapper));
        }
Beispiel #2
0
        /// <summary>
        /// Convert table to target enumerable
        /// </summary>
        /// <typeparam name="T">Target type</typeparam>
        /// <param name="table">Table</param>
        /// <returns>Target enumerable</returns>
        public static IEnumerable <T> Convert <T>(this Table table) where T : new()
        {
            var mapper = new TableMapper <T>();

            mapper.Extract();
            return(Convert <T>(table, mapper));
        }
Beispiel #3
0
        /// <summary>
        /// Convert table to target enumerable
        /// </summary>
        /// <param name="table">Table</param>
        /// <param name="type">Target type</param>
        /// <param name="expression">Mapping expression</param>
        /// <param name="exclude">One-based row indices to exclude</param>
        /// <returns>Target enumerable</returns>
        public static IEnumerable <object> Convert(this Table table, Type type, string expression, params int[] exclude)
        {
            var generator = new TableMapper(type).Map(expression);

            if (exclude != null && exclude.Length > 0)
            {
                generator.Exclude(exclude);
            }
            return(Convert(table, generator));
        }
Beispiel #4
0
        /// <summary>
        /// Convert table to target enumerable
        /// </summary>
        /// <typeparam name="T">Target type</typeparam>
        /// <param name="table">Table</param>
        /// <param name="expression">Mapping expression</param>
        /// <param name="exclude">One-based row indices to exclude</param>
        /// <returns>Target enumerable</returns>
        public static IEnumerable <T> Convert <T>(this Table table, string expression, params int[] exclude) where T : new()
        {
            var generator = new TableMapper <T>().Map(expression);

            if (exclude != null && exclude.Length > 0)
            {
                generator.Exclude(exclude);
            }
            return(Convert(table, generator));
        }
Beispiel #5
0
        /// <summary>
        /// Convert table to target enumerable
        /// </summary>
        /// <typeparam name="T">Target type</typeparam>
        /// <param name="table">Table</param>
        /// <param name="row">One-based mapping provider row index</param>
        /// <returns>Target enumerable</returns>
        public static IEnumerable <T> Convert <T>(this Table table, int row) where T : new()
        {
            if (row < 1)
            {
                throw new ArgumentException("One-based row index must be greater than 0");
            }
            ITableGenerator <T> generator = new TableMapper <T>().Map(table[row - 1]).Exclude(row);

            return(generator.Instantiate(table));
        }
Beispiel #6
0
        /// <summary>
        /// Convert table to target enumerable
        /// </summary>
        /// <param name="table">Table</param>
        /// <param name="type">Target type</param>
        /// <param name="row">One-based mapping provider row index</param>
        /// <returns>Target enumerable</returns>
        public static IEnumerable <object> Convert(this Table table, Type type, int row, bool safeMode = false)
        {
            if (row < 1)
            {
                throw new ArgumentException("One-based row index must be greater than 0");
            }
            var map = new TableMapper(type).Map(table[row - 1]).Exclude(row);

            map.SafeMode = safeMode;
            ITableGenerator generator = map;

            return(generator.Instantiate(table));
        }