Advertisement
Guest User

Untitled

a guest
Apr 21st, 2014
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. MainObject
  2. List<NestedObject>
  3. NestedObject
  4. List<ChildObject>
  5. ChildObject
  6. ChildObject
  7. ChildObject
  8. List<ChildObject>
  9. ChildObject
  10. ChildObject
  11. List<NestedObject>
  12. NestedObject
  13. List<ChildObject>
  14. ChildObject
  15. List<ChildObject>
  16. ChildObject
  17. ChildObject
  18. NestedObject
  19. List<ChildObject>
  20. ChildObject
  21. ChildObject
  22.  
  23. private IEnumerable<T> Iterate<T>(Type type)
  24. {
  25. foreach(var p in typeof(type).GetProperties()) {
  26. IEnumerable<T> collection = p as IEnumerable<T>;
  27. if (collection != null){
  28. return collection
  29. .OfType<T>()
  30. .Concat<T>(property.SelectMany(p => Iterate<T>(p)));
  31. }
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement