microsoft/teams.net
Publicmirrored fromhttps://github.com/microsoft/teams.netAvailable
Libraries/Microsoft.Teams.Cards/Actions/TaskFetchAction.cs
38lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | using Microsoft.Teams.Common; |
| 5 | |
| 6 | namespace Microsoft.Teams.Cards; |
| 7 | |
| 8 | public class TaskFetchAction : SubmitAction |
| 9 | { |
| 10 | public TaskFetchAction(IDictionary<string, object?>? value = null) |
| 11 | { |
| 12 | var submitActionData = new SubmitActionData |
| 13 | { |
| 14 | MsTeams = new TaskFetchSubmitActionData() |
| 15 | }; |
| 16 | |
| 17 | if (value != null) |
| 18 | { |
| 19 | foreach (var kvp in value) |
| 20 | { |
| 21 | submitActionData.NonSchemaProperties[kvp.Key] = kvp.Value; |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | Data = new Union<string, SubmitActionData>(submitActionData); |
| 26 | } |
| 27 | |
| 28 | public static IDictionary<string, object?> FromObject(object obj) |
| 29 | { |
| 30 | if (obj == null) throw new ArgumentNullException(nameof(obj)); |
| 31 | |
| 32 | return obj.GetType() |
| 33 | .GetProperties() |
| 34 | .ToDictionary( |
| 35 | p => p.Name, |
| 36 | p => (object?)p.GetValue(obj)); |
| 37 | } |
| 38 | } |