示例#1
0
        public static IDataSource <T> Process <T>(this IEnumerable <T> enumerable, Func <T, T> processor, bool dispose = true)
        {
            ListDataSource <T> output = new ListDataSource <T>();

            foreach (T item in enumerable)
            {
                output.Add(processor(item));
            }
            if (dispose)
            {
                enumerable = null;
            }
            return(output);
        }
示例#2
0
        public static IDataSource <TOutput> Transform <TInput, TOutput>(this IEnumerable <TInput> enumerable,
                                                                        Func <TInput, TOutput> transormer, bool dispose = true)
        {
            ListDataSource <TOutput> output = new ListDataSource <TOutput>();

            foreach (TInput input in enumerable)
            {
                output.Add(transormer(input));
            }
            if (dispose)
            {
                enumerable = null;
            }
            return(output);
        }
示例#3
0
        public static IDataSource <T> FilterBy <T>(this IEnumerable <T> enumerable, Func <T, bool> condition, bool dispose = true)
        {
            ListDataSource <T> output = new ListDataSource <T>();

            foreach (T item in enumerable)
            {
                if (condition(item))
                {
                    output.Add(item);
                }
                else
                {
                    output.ThrownAway.Add(item);
                }
            }
            if (dispose)
            {
                enumerable = null;
            }
            return(output);
        }