microsoft/teams.net

Public

mirrored from https://github.com/microsoft/teams.netAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v2.0.1

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

Libraries/Microsoft.Teams.Api/Activities/EventActivity.cs

54lines · modecode

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