示例#1
0
 //returns nested indexed data from provided ids
 //counter counts how many levels of nesting have been reached
 public DataItem GetIndexedData(int[] sentIds, int counter = 0)
 {
     DataItem[] tempDataArray = GetArray();
     //if the desired nested depth has been reached, return this item
     if (counter >= sentIds.Length)
     {
         return(this);
     }
     //otherwise get an item from the array
     for (int i = 0; i < tempDataArray.Length; i++)
     {
         //check if this array item's data matches the sent index
         if (tempDataArray[i].ID == sentIds[counter])
         {
             if (tempDataArray[i] is IIndexable)
             {
                 IIndexable indexable = (IIndexable)tempDataArray[i];
                 //continue to retrieve data from indexables until desired depth is reached
                 DataItem dataItem = indexable.GetIndexedData(sentIds, counter + 1);
                 return(dataItem);
             }
         }
     }
     return(null);
 }