microsoft/teams.net
Publicmirrored fromhttps://github.com/microsoft/teams.netAvailable
Libraries/Microsoft.Teams.Cards/Utilities/SubmitData.cs
32lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | namespace Microsoft.Teams.Cards; |
| 5 | |
| 6 | /// <summary> |
| 7 | /// Utility class for creating submit data with action-based routing. |
| 8 | /// |
| 9 | /// Extends the generated <see cref="SubmitActionData"/> with a convenience constructor |
| 10 | /// that accepts an action identifier for handler routing. |
| 11 | /// </summary> |
| 12 | /// <example> |
| 13 | /// <code> |
| 14 | /// new ExecuteAction { Data = new Union<string, SubmitActionData>(new SubmitData("save_profile", new() { ["entity_id"] = "12345" })) } |
| 15 | /// </code> |
| 16 | /// </example> |
| 17 | public class SubmitData : SubmitActionData |
| 18 | { |
| 19 | private const string ReservedKeyword = "action"; |
| 20 | |
| 21 | public SubmitData(string action, IDictionary<string, object?>? extraData = null) |
| 22 | { |
| 23 | if (extraData != null) |
| 24 | { |
| 25 | foreach (var kvp in extraData) |
| 26 | { |
| 27 | NonSchemaProperties[kvp.Key] = kvp.Value; |
| 28 | } |
| 29 | } |
| 30 | NonSchemaProperties[ReservedKeyword] = action; |
| 31 | } |
| 32 | } |