OperatList.cs 981 B

12345678910111213141516171819202122232425262728293031323334353637
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace Ant.ORM
  6. {
  7. public class OperatList
  8. {
  9. public delegate void ShowHandler();
  10. public void Show(ShowHandler hander)
  11. {
  12. hander();
  13. }
  14. public static void ActionWithSearch<T>(List<T> items, Func<T, bool> condition, Action<T> action)
  15. {
  16. List<T> results = items.Where(condition).ToList<T>();
  17. foreach (var item in results)
  18. {
  19. action(item);
  20. }
  21. }
  22. public delegate bool SearchStr<T>(T item);
  23. public static List<T> GetWhereList<T>(List<T> items, SearchStr<T> condition)
  24. {
  25. List<T> results = new List<T>();
  26. foreach (T item in items)
  27. {
  28. if (condition(item))
  29. {
  30. results.Add(item);
  31. }
  32. }
  33. return results;
  34. }
  35. }
  36. }