예제 #1
0
        public static List <TObject> CopySpecificationToList <TObject>(IEnumerable <TObject> source, Predicate <TObject> predicate)
        {
            List <TObject> copy = new List <TObject>();

            CollectionHelper.ActionOnSpecification <TObject>(source, delegate(TObject t) { copy.Add(t); }, predicate);
            return(copy);
        }
예제 #2
0
        /// <summary>
        /// ConvertSpecification 将source中的符合predicate条件元素转换为TResult类型
        /// </summary>
        public static List <TResult> ConvertSpecification <TObject, TResult>(IEnumerable <TObject> source, CommonMethod.Func <TObject, TResult> converter, Predicate <TObject> predicate)
        {
            List <TResult> list = new List <TResult>();

            CollectionHelper.ActionOnSpecification <TObject>(source, delegate(TObject ele) { list.Add(converter(ele)); }, predicate);
            return(list);
        }