/// <summary> /// Adds multiple choices. /// </summary> /// <typeparam name="T">The prompt result type.</typeparam> /// <param name="obj">The prompt.</param> /// <param name="choices">The choices to add.</param> /// <returns>The same instance so that multiple calls can be chained.</returns> public static MultiSelectionPrompt <T> AddChoices <T>(this MultiSelectionPrompt <T> obj, IEnumerable <T> choices) where T : notnull { if (obj is null) { throw new ArgumentNullException(nameof(obj)); } foreach (var choice in choices) { obj.AddChoice(choice); } return(obj); }
/// <summary> /// Adds multiple grouped choices. /// </summary> /// <typeparam name="T">The prompt result type.</typeparam> /// <param name="obj">The prompt.</param> /// <param name="group">The group.</param> /// <param name="choices">The choices to add.</param> /// <returns>The same instance so that multiple calls can be chained.</returns> public static MultiSelectionPrompt <T> AddChoiceGroup <T>(this MultiSelectionPrompt <T> obj, T group, IEnumerable <T> choices) where T : notnull { if (obj is null) { throw new ArgumentNullException(nameof(obj)); } var root = obj.AddChoice(group); foreach (var choice in choices) { root.AddChild(choice); } return(obj); }
/// <summary> /// Adds a choice. /// </summary> /// <typeparam name="T">The prompt result type.</typeparam> /// <param name="obj">The prompt.</param> /// <param name="choice">The choice to add.</param> /// <param name="configurator">The configurator for the choice.</param> /// <returns>The same instance so that multiple calls can be chained.</returns> public static MultiSelectionPrompt <T> AddChoices <T>(this MultiSelectionPrompt <T> obj, T choice, Action <IMultiSelectionItem <T> > configurator) where T : notnull { if (obj is null) { throw new ArgumentNullException(nameof(obj)); } if (configurator is null) { throw new ArgumentNullException(nameof(configurator)); } var result = obj.AddChoice(choice); configurator(result); return(obj); }