microsoft/teams.net
Publicmirrored fromhttps://github.com/microsoft/teams.netAvailable
Libraries/Microsoft.Teams.Api/Activities/EventActivity.cs
55lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | using System.Text.Json.Serialization; |
| 5 | |
| 6 | using Microsoft.Teams.Common; |
| 7 | |
| 8 | namespace Microsoft.Teams.Api.Activities; |
| 9 | |
| 10 | public partial class ActivityType : StringEnum |
| 11 | { |
| 12 | public static readonly ActivityType Event = new("event"); |
| 13 | public bool IsEvent => Event.Equals(Value); |
| 14 | } |
| 15 | |
| 16 | [JsonConverter(typeof(JsonConverter))] |
| 17 | public interface IEventActivity : IActivity |
| 18 | { |
| 19 | /// <summary> |
| 20 | /// The name of the operation associated with an invoke or event activity. |
| 21 | /// </summary> |
| 22 | public Events.Name Name { get; set; } |
| 23 | } |
| 24 | |
| 25 | [JsonConverter(typeof(JsonConverter))] |
| 26 | public partial class EventActivity(Events.Name name) : Activity(ActivityType.Event), IEventActivity |
| 27 | { |
| 28 | /// <summary> |
| 29 | /// The name of the operation associated with an invoke or event activity. |
| 30 | /// </summary> |
| 31 | [JsonPropertyName("name")] |
| 32 | [JsonPropertyOrder(31)] |
| 33 | public Events.Name Name { get; set; } = name; |
| 34 | |
| 35 | public override string GetPath() |
| 36 | { |
| 37 | return string.Join(".", ["Activity", Type.ToPrettyString(), Name.ToPrettyString()]); |
| 38 | } |
| 39 | |
| 40 | public Events.MeetingStartActivity ToMeetingStart() => (Events.MeetingStartActivity)this; |
| 41 | public Events.MeetingEndActivity ToMeetingEnd() => (Events.MeetingEndActivity)this; |
| 42 | public Events.MeetingParticipantJoinActivity ToMeetingParticipantJoin() => (Events.MeetingParticipantJoinActivity)this; |
| 43 | public Events.MeetingParticipantLeaveActivity ToMeetingParticipantLeave() => (Events.MeetingParticipantLeaveActivity)this; |
| 44 | public Events.ReadReceiptActivity ToReadReceipt() => (Events.ReadReceiptActivity)this; |
| 45 | |
| 46 | public override object ToType(Type type, IFormatProvider? provider) |
| 47 | { |
| 48 | if (type == Events.Name.ReadReceipt.ToType()) return ToReadReceipt(); |
| 49 | if (type == Events.Name.MeetingStart.ToType()) return ToMeetingStart(); |
| 50 | if (type == Events.Name.MeetingEnd.ToType()) return ToMeetingEnd(); |
| 51 | if (type == Events.Name.MeetingParticipantJoin.ToType()) return ToMeetingParticipantJoin(); |
| 52 | if (type == Events.Name.MeetingParticipantLeave.ToType()) return ToMeetingParticipantLeave(); |
| 53 | return this; |
| 54 | } |
| 55 | } |