Beispiel #1
0
        private IEnumerable <T> RecursiveEnumerate <T>(TmxLayerNode layerNode) where T : TmxLayerNode
        {
            // Is this node the type we're looking for?
            if (layerNode.GetType() == typeof(T))
            {
                yield return((T)layerNode);
            }

            // Go through all children nodes
            foreach (var child in layerNode.LayerNodes)
            {
                foreach (var recursive in RecursiveEnumerate <T>(child))
                {
                    yield return(recursive);
                }
            }
        }
Beispiel #2
0
 private IEnumerable <T> RecursiveEnumerate <T>(TmxLayerNode layerNode) where T : TmxLayerNode
 {
     if (layerNode.GetType() == typeof(T))
     {
         yield return((T)layerNode);
     }
     List <TmxLayerNode> .Enumerator enumerator = layerNode.LayerNodes.GetEnumerator();
     try
     {
         while (enumerator.MoveNext())
         {
             TmxLayerNode current = enumerator.Current;
             foreach (T item in RecursiveEnumerate <T>(current))
             {
                 yield return(item);
             }
         }
     }
     finally
     {
         ((IDisposable)enumerator).Dispose();
     }
     enumerator = default(List <TmxLayerNode> .Enumerator);
 }