Esempio n. 1
0
 /// <summary>
 /// Find a child by its name
 /// </summary>
 /// <param name="dict">accu sets</param>
 /// <param name="name">structured multiple names separated by a dot</param>
 /// <returns>element found</returns>
 public static AccuChild RecursiveFindByName(Dictionary <string, Accu> dict, string name)
 {
     string[] seq = name.Split('.');
     if (seq.Length > 1)
     {
         if (dict.ContainsKey(seq[0]))
         {
             Accu a = dict[seq[0]];
             if (a.Variables.ContainsKey(seq[1]))
             {
                 return(AccuChild.RecursiveFindByName(a.Variables[seq[1]] as AccuChild, 2, seq));
             }
             else
             {
                 throw new KeyNotFoundException(String.Format("{0} not found", seq[1]));
             }
         }
         else
         {
             throw new KeyNotFoundException(String.Format("{0} not found", seq[0]));
         }
     }
     else
     {
         throw new ArgumentException("bad name", "name");
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Find a child by its name
 /// </summary>
 /// <param name="root">root accu</param>
 /// <param name="index">index position</param>
 /// <param name="seq">sequence name</param>
 /// <returns>element found</returns>
 public static AccuChild RecursiveFindByName(Accu root, int index, string[] seq)
 {
     if (index < seq.Length)
     {
         AccuChild a = root.Values.Last(x => x.Name == seq[index]) as AccuChild;
         return(AccuChild.RecursiveFindByName(a, index + 1, seq));
     }
     else
     {
         throw new FormatException();
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Find a child by its name
 /// </summary>
 /// <param name="child">root accu</param>
 /// <param name="index">index position</param>
 /// <param name="seq">sequence name</param>
 /// <returns>element found</returns>
 public static AccuChild RecursiveFindByName(AccuChild child, int index, string[] seq)
 {
     if (index < seq.Length)
     {
         AccuChild a = child.IncludedVariables[seq[index]] as AccuChild;
         return(AccuChild.RecursiveFindByName(a, index + 1, seq));
     }
     else
     {
         return(child);
     }
 }