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); }
/// <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); }