mirror of
				https://github.com/nsnail/spectre.console.git
				synced 2025-10-31 17:15:28 +08:00 
			
		
		
		
	add overload taking params array (#682)
This commit is contained in:
		| @@ -122,6 +122,31 @@ public static class MultiSelectionPromptExtensions | ||||
|         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, params 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> | ||||
|     /// Marks an item as selected. | ||||
|     /// </summary> | ||||
|   | ||||
| @@ -95,6 +95,31 @@ public static class SelectionPromptExtensions | ||||
|         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 SelectionPrompt<T> AddChoiceGroup<T>(this SelectionPrompt<T> obj, T group, params 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> | ||||
|     /// Sets the title. | ||||
|     /// </summary> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Steven
					Steven