| 762 | } |
| 763 | |
| 764 | private void AddImpl (Option option) |
| 765 | { |
| 766 | if (option == null) |
| 767 | throw new ArgumentNullException ("option"); |
| 768 | List<string> added = new List<string> (option.Names.Length); |
| 769 | try { |
| 770 | // KeyedCollection.InsertItem/SetItem handle the 0th name. |
| 771 | for (int i = 1; i < option.Names.Length; ++i) { |
| 772 | Dictionary.Add (option.Names [i], option); |
| 773 | added.Add (option.Names [i]); |
| 774 | } |
| 775 | } |
| 776 | catch (Exception) { |
| 777 | foreach (string name in added) |
| 778 | Dictionary.Remove (name); |
| 779 | throw; |
| 780 | } |
| 781 | } |
| 782 | |
| 783 | public OptionSet Add (string header) |
| 784 | { |