forked from smiley22/S22.Mail
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ContentTransferEncoding.cs
58 lines (56 loc) · 1.75 KB
/
ContentTransferEncoding.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
using System;
using System.Collections.Generic;
namespace S22.Imap {
/// <summary>
/// Possible values for the "Encoding" property of the Bodypart class. The content
/// transfer encoding indicates whether or not a binary-to-text encoding
/// scheme has been used on top of the original encoding as specified within the
/// Content-Type header.
/// </summary>
public enum ContentTransferEncoding {
/// <summary>
/// The content tranfer encoding could not be determined or is unknown.
/// </summary>
Unknown,
/// <summary>
/// Up to 998 bytes per line of the code range 1 - 127 with CR and LF only
/// allowed to appear as part of a CRLF line ending.
/// </summary>
Bit7,
/// <summary>
/// Up to 998 bytes per line with CR and LF only allowed to appear as part
/// of a CRLF line ending.
/// </summary>
Bit8,
/// <summary>
/// Any sequence of bytes.
/// </summary>
Binary,
/// <summary>
/// Byte sequence is encoded using the quoted-printable encoding.
/// </summary>
QuotedPrintable,
/// <summary>
/// Byte sequence is encoded using Base64 encoding.
/// </summary>
Base64
}
internal static class ContentTransferEncodingMap {
public static ContentTransferEncoding fromString(string transferEncoding) {
Dictionary<string, ContentTransferEncoding> Map =
new Dictionary<string, ContentTransferEncoding>
(StringComparer.OrdinalIgnoreCase) {
{ "7Bit", ContentTransferEncoding.Bit7 },
{ "8Bit", ContentTransferEncoding.Bit8 },
{ "Binary", ContentTransferEncoding.Binary },
{ "Quoted-Printable", ContentTransferEncoding.QuotedPrintable },
{ "Base64", ContentTransferEncoding.Base64 }
};
try {
return Map[transferEncoding];
} catch {
return ContentTransferEncoding.Unknown;
}
}
}
}