protected static BO.Taxonomy.BOTaxon GetTaxonDescendant(BO.Taxonomy.BOTaxon Taxon, BO.Taxonomy.TaxonTypeEnum RequiredDescendant, CustomConditionDelegate CustomCondition, object[] CustomConditionArgs) { if (RequiredDescendant != BO.Taxonomy.TaxonTypeEnum.Stock) { //Check if the supplied Taxon is the one required. if (Taxon.TaxonType == RequiredDescendant) { //Check if there are any custom tests to run. if (CustomCondition != null) { return(CustomCondition(Taxon, CustomConditionArgs)); } else { return(Taxon); } } else //The supplied taxon is not the one required. { BO.Taxonomy.BOTaxon[] LowerTaxa = Taxon.GetLowerTaxa(); BO.Taxonomy.BOTaxon GotTaxon = null; //Check that there are children. if (LowerTaxa.Length > 0) { System.Int32 x = 0; //Loop all the child taxon until one is returned. while (GotTaxon == null & x < LowerTaxa.Length) { GotTaxon = GetTaxonDescendant(LowerTaxa[x], RequiredDescendant, CustomCondition, CustomConditionArgs); x++; } return(GotTaxon); } else //The supplied taxon does not have any children. { return(null); } } } else { throw new ApplicationException("Cannot search for Stock name as these do not form part of the hierarchy"); } }
protected static BO.Taxonomy.BOTaxon GetTaxonDescendant(BO.Taxonomy.BOTaxon Taxon, BO.Taxonomy.TaxonTypeEnum RequiredDescendant, CustomConditionDelegate CustomCondition) { return(GetTaxonDescendant(Taxon, RequiredDescendant, CustomCondition, null)); }