title: yield return in recursion
body: <p>i am attempting to create an </p>
  
  <pre><code>    IEnumrable&lt;PropertyInfo&gt; 
  </code></pre>
  
  <p>iv'e got a method called Disassemble which iterates recursively throw a given object and all it's child objects of it's properties .</p>
  
  <p><strong>please do not concern your self with the Inner wrapper objects of type INameValueWrapper</strong></p>
  
  <p>The problem below is when i encounter a property which is a Class i wan't to call Disassemble on it as well 
  and add it to the same iteration of the IEnumrable , the Dissasemble does not occur again when it is called 
  where i put the comment :
      <strong>// The problem is here .</strong></p>
  
  <pre><code>    public static IEnumerable&lt;T&gt; Dissasemble&lt;T&gt;(this object sourceObj) where T : INameValueWrapper
      {
          var properties = sourceObj.GetType().GetProperties();
  
          foreach (var prop in properties)
          {
              var wrapper = (T)prop.WrapPropertyInfo(sourceObj);
              yield return wrapper;
  
              if (wrapper is CollectionPropertyInfoWrapper)
              {
                  var colWrapper = wrapper as CollectionPropertyInfoWrapper;
                  var collection = (IList)colWrapper.Value;
  
                  int index = 0;
                  foreach (var item in collection)
                  {
                      yield return (T)item.WrapItem(collection, index + 1);
                      index++;
                  }
              }
              else
              {
                  var propWrapper = wrapper as PropertyInfoWrapper;
                  if (!propWrapper.IsPrimitive)
                  {
                      var childObject = prop.GetValue(sourceObj);
                      childObject.Dissasemble&lt;T&gt;(); // here is the problem 
                  }
              }
          }
  
          yield break;
      } 
  </code></pre>
  
  <p>1) Why does it not get called and added to the iteration ?</p>
  
  <p>2) What is the work around this issue ? , </p>
  
  <pre><code> i could call childObject.Dissasemble&lt;T&gt;().ToList() 
   and then iterate that collection calling yield return on it's items 
   but that seems like re doing something i already did.
  </code></pre>
  
  <p>thanks in advance.</p>