-
Notifications
You must be signed in to change notification settings - Fork 0
/
Organizer.cs
64 lines (55 loc) · 1.48 KB
/
Organizer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;
namespace MeetingRequest
{
/// <summary>
/// Organizer for a calendar component.
/// </summary>
[DataContract]
public class Organizer
{
/// <summary>
/// Public name (CN)
/// </summary>
[DataMember]
public string PublicName { get; set; }
/// <summary>
/// Email
/// </summary>
[DataMember]
public string Email { get; set; }
/// <summary>
/// Role
/// </summary>
[DataMember]
public Role Role { get; set; }
/// <summary>
/// Create a new organizer
/// </summary>
public Organizer()
{
this.Role = Role.CHAIR;
}
/// <summary>
/// Return an organizer class in RFC-2445 format
/// </summary>
internal string GetFormattedElement()
{
StringBuilder sb = new StringBuilder();
List<string> items = new List<string>();
var role = RoleHelper.Convert(this.Role);
if (role != null)
items.Add("ROLE=" + role);
if (!string.IsNullOrEmpty(this.PublicName))
items.Add("CN=" + this.PublicName.ReplaceForCal());
for (int i = 0; i < items.Count; ++i)
{
sb.Append(items[i]);
sb.Append((i == items.Count - 1) ? ":" : ";");
}
sb.Append("MAILTO:" + this.Email.ReplaceForCal());
return sb.ToString();
}
}
}