microsoft/teams.net
Publicmirrored fromhttps://github.com/microsoft/teams.netAvailable
Libraries/Microsoft.Teams.Cards/Utilities/OpenDialogData.cs
34lines · 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 | /// Convenience class for creating the data payload to open a dialog |
| 8 | /// from an Action.Submit. |
| 9 | /// |
| 10 | /// Abstracts away the <c>msteams: { type: "task/fetch" }</c> protocol detail |
| 11 | /// and sets a reserved <c>dialog_id</c> field for handler routing. |
| 12 | /// </summary> |
| 13 | /// <example> |
| 14 | /// <code> |
| 15 | /// new SubmitAction { Data = new Union<string, SubmitActionData>(new OpenDialogData("simple_form")) } |
| 16 | /// </code> |
| 17 | /// </example> |
| 18 | public class OpenDialogData : SubmitActionData |
| 19 | { |
| 20 | private const string ReservedKeyword = "dialog_id"; |
| 21 | |
| 22 | public OpenDialogData(string dialogId, IDictionary<string, object?>? extraData = null) |
| 23 | { |
| 24 | Msteams = new TaskFetchSubmitActionData(); |
| 25 | if (extraData != null) |
| 26 | { |
| 27 | foreach (var kvp in extraData) |
| 28 | { |
| 29 | NonSchemaProperties[kvp.Key] = kvp.Value; |
| 30 | } |
| 31 | } |
| 32 | NonSchemaProperties[ReservedKeyword] = dialogId; |
| 33 | } |
| 34 | } |