public string GenerateSlotFor(Relation2GeomType _type, bool _for_subcomponents) { int slot_counter = 0; int iteration_guard = 100; string slot = ComponentUtils.Relation2GeomTypeToSlot(_type) + ComponentUtils.COMP_SLOT_DELIMITER + "AG" + slot_counter.ToString(); // check if the component already has such a slot if (_for_subcomponents) { while (this.ContainedComponents.ContainsKey(slot) && slot_counter < iteration_guard) { slot_counter++; slot = ComponentUtils.Relation2GeomTypeToSlot(_type) + ComponentUtils.COMP_SLOT_DELIMITER + "AG" + slot_counter.ToString(); } if (this.ContainedComponents.ContainsKey(slot)) { return(null); // something went very wrong! } } else { while (this.ReferencedComponents.ContainsKey(slot) && slot_counter < iteration_guard) { slot_counter++; slot = ComponentUtils.Relation2GeomTypeToSlot(_type) + ComponentUtils.COMP_SLOT_DELIMITER + "AG" + slot_counter.ToString(); } if (this.ReferencedComponents.ContainsKey(slot)) { return(null); // something went very wrong! } } return(slot); }