private bool _findIt(FindEnum findThis, string forThis, GraphicFolderType inThis, string whereWeAre, ref string whereItIs) { // Recursive function that looks for a particular type of attribute (findThis), belonging to // a particular JMSML entity (forThis) in the specified graphic folder object (inThis). // If it's found we return the path we found it at (whereItIs) all the way up the recursion chain, // based on a path string we've been building as we recurse (whereWeAre). // If we don't find it, we continue with a depth first search until we do find it or run // out of graphic folders to search. bool foundIt = false; if (inThis != null) { // First look for what we are searching for in this folder // If it is here then append this folder's name to our path // and return immediately. whereWeAre = whereWeAre + "\\" + inThis.Name; // Based on what we are looking for, here is where we check // the current folder for the attribute value we want. switch (findThis) { case FindEnum.FindAuxiliaryEquipment: foundIt = inThis.AuxiliaryEquipment; break; case FindEnum.FindEchelons: foundIt = inThis.Echelons; break; case FindEnum.FindEntities: if (inThis.Entities != null) { foundIt = _splitAndSearch(inThis.Entities, forThis); } break; case FindEnum.FindFrames: if (inThis.Frames != null) { foundIt = _splitAndSearch(inThis.Frames, forThis); } break; case FindEnum.FindHQTFFD: foundIt = inThis.HQTFFD; break; case FindEnum.FindMobilities: foundIt = inThis.Mobilities; break; case FindEnum.FindModifierOnes: if (inThis.ModifierOnes != null) { foundIt = _splitAndSearch(inThis.ModifierOnes, forThis); } break; case FindEnum.FindModifierTwos: if (inThis.ModifierTwos != null) { foundIt = _splitAndSearch(inThis.ModifierTwos, forThis); } break; case FindEnum.FindSpecials: foundIt = inThis.Specials; break; case FindEnum.FindOCA: foundIt = inThis.OCA; break; case FindEnum.Find2525C: foundIt = inThis.LegacyStandard == "2525C"; break; case FindEnum.Find2525BC2: foundIt = inThis.LegacyStandard == "2525BC2"; break; } if (foundIt) { // We found it here so lets determine where we are so // we can return that information up the recursion chain. whereItIs = whereWeAre; } else { // No luck finding it here, so let's look deeper if (inThis.GraphicFolder != null) { foreach (GraphicFolderType childFolder in inThis.GraphicFolder) { foundIt = _findIt(findThis, forThis, childFolder, whereWeAre, ref whereItIs); if (foundIt) { break; } } } } } return(foundIt); }
private bool _findIt(FindEnum findThis, string forThis, GraphicFolderType inThis, string whereWeAre, ref string whereItIs) { // Recursive function that looks for a particular type of attribute (findThis), belonging to // a particular JMSML entity (forThis) in the specified graphic folder object (inThis). // If it's found we return the path we found it at (whereItIs) all the way up the recursion chain, // based on a path string we've been building as we recurse (whereWeAre). // If we don't find it, we continue with a depth first search until we do find it or run // out of graphic folders to search. bool foundIt = false; if (inThis != null) { // First look for what we are searching for in this folder // If it is here then append this folder's name to our path // and return immediately. whereWeAre = whereWeAre + "\\" + inThis.Name; // Based on what we are looking for, here is where we check // the current folder for the attribute value we want. switch (findThis) { case FindEnum.FindAuxiliaryEquipment: foundIt = inThis.AuxiliaryEquipment; break; case FindEnum.FindEchelons: foundIt = inThis.Echelons; break; case FindEnum.FindEntities: if (inThis.Entities != null) { foundIt = _splitAndSearch(inThis.Entities, forThis); } break; case FindEnum.FindFrames: if (inThis.Frames != null) { foundIt = _splitAndSearch(inThis.Frames, forThis); } break; case FindEnum.FindHQTFFD: foundIt = inThis.HQTFFD; break; case FindEnum.FindMobilities: foundIt = inThis.Mobilities; break; case FindEnum.FindModifierOnes: if (inThis.ModifierOnes != null) { foundIt = _splitAndSearch(inThis.ModifierOnes, forThis); } break; case FindEnum.FindModifierTwos: if (inThis.ModifierTwos != null) { foundIt = _splitAndSearch(inThis.ModifierTwos, forThis); } break; case FindEnum.FindSpecials: foundIt = inThis.Specials; break; case FindEnum.FindOCA: foundIt = inThis.OCA; break; } if (foundIt) { // We found it here so lets determine where we are so // we can return that information up the recursion chain. whereItIs = whereWeAre; } else { // No luck finding it here, so let's look deeper if (inThis.GraphicFolder != null) { foreach (GraphicFolderType childFolder in inThis.GraphicFolder) { foundIt = _findIt(findThis, forThis, childFolder, whereWeAre, ref whereItIs); if (foundIt) break; } } } } return foundIt; }