using System; using System.Collections; using System.Collections.Specialized; using System.Globalization; using System.Text; namespace System.Net.Mime { /// Represents a MIME protocol Content-Disposition header. // Token: 0x0200014E RID: 334 public class ContentDisposition { /// Initializes a new instance of the class with a of . // Token: 0x06000B6C RID: 2924 RVA: 0x00023020 File Offset: 0x00021220 public ContentDisposition() : this("attachment") { } /// Initializes a new instance of the class with the specified disposition information. /// A value that contains the disposition. /// /// is null or equal to (""). // Token: 0x06000B6D RID: 2925 RVA: 0x00023030 File Offset: 0x00021230 public ContentDisposition(string disposition) { if (disposition == null) { throw new ArgumentNullException(); } if (disposition.Length < 1) { throw new FormatException(); } this.Size = -1L; try { int num = disposition.IndexOf(';'); if (num < 0) { this.dispositionType = disposition.Trim(); } else { string[] array = disposition.Split(new char[] { ';' }); this.dispositionType = array[0].Trim(); for (int i = 1; i < array.Length; i++) { this.Parse(array[i]); } } } catch { throw new FormatException(); } } // Token: 0x06000B6E RID: 2926 RVA: 0x00023100 File Offset: 0x00021300 private void Parse(string pair) { if (pair == null || pair.Length < 0) { return; } string[] array = pair.Split(new char[] { '=' }); if (array.Length == 2) { this.parameters.Add(array[0].Trim(), array[1].Trim()); return; } throw new FormatException(); } /// Gets or sets the creation date for a file attachment. /// A value that indicates the file creation date; otherwise, if no date was specified. // Token: 0x170002DB RID: 731 // (get) Token: 0x06000B6F RID: 2927 RVA: 0x00023164 File Offset: 0x00021364 // (set) Token: 0x06000B70 RID: 2928 RVA: 0x000231A8 File Offset: 0x000213A8 public DateTime CreationDate { get { if (this.parameters.ContainsKey("creation-date")) { return DateTime.ParseExact(this.parameters["creation-date"], "dd MMM yyyy HH':'mm':'ss zz00", null); } return DateTime.MinValue; } set { if (value > DateTime.MinValue) { this.parameters["creation-date"] = value.ToString("dd MMM yyyy HH':'mm':'ss zz00"); } else { this.parameters.Remove("modification-date"); } } } /// Gets or sets the disposition type for an e-mail attachment. /// A that contains the disposition type. The value is not restricted but is typically one of the values. /// The value specified for a set operation is null. /// The value specified for a set operation is equal to (""). // Token: 0x170002DC RID: 732 // (get) Token: 0x06000B71 RID: 2929 RVA: 0x000231F8 File Offset: 0x000213F8 // (set) Token: 0x06000B72 RID: 2930 RVA: 0x00023200 File Offset: 0x00021400 public string DispositionType { get { return this.dispositionType; } set { if (value == null) { throw new ArgumentNullException(); } if (value.Length < 1) { throw new ArgumentException(); } this.dispositionType = value; } } /// Gets or sets the suggested file name for an e-mail attachment. /// A that contains the file name. // Token: 0x170002DD RID: 733 // (get) Token: 0x06000B73 RID: 2931 RVA: 0x00023228 File Offset: 0x00021428 // (set) Token: 0x06000B74 RID: 2932 RVA: 0x0002323C File Offset: 0x0002143C public string FileName { get { return this.parameters["filename"]; } set { this.parameters["filename"] = value; } } /// Gets or sets a value that determines the disposition type (Inline or Attachment) for an e-mail attachment. /// true if content in the attachment is presented inline as part of the e-mail body; otherwise, false. // Token: 0x170002DE RID: 734 // (get) Token: 0x06000B75 RID: 2933 RVA: 0x00023250 File Offset: 0x00021450 // (set) Token: 0x06000B76 RID: 2934 RVA: 0x0002326C File Offset: 0x0002146C public bool Inline { get { return string.Compare(this.dispositionType, "inline", true, CultureInfo.InvariantCulture) == 0; } set { if (value) { this.dispositionType = "inline"; } else { this.dispositionType = "attachment"; } } } /// Gets or sets the modification date for a file attachment. /// A value that indicates the file modification date; otherwise, if no date was specified. // Token: 0x170002DF RID: 735 // (get) Token: 0x06000B77 RID: 2935 RVA: 0x00023290 File Offset: 0x00021490 // (set) Token: 0x06000B78 RID: 2936 RVA: 0x000232D4 File Offset: 0x000214D4 public DateTime ModificationDate { get { if (this.parameters.ContainsKey("modification-date")) { return DateTime.ParseExact(this.parameters["modification-date"], "dd MMM yyyy HH':'mm':'ss zz00", null); } return DateTime.MinValue; } set { if (value > DateTime.MinValue) { this.parameters["modification-date"] = value.ToString("dd MMM yyyy HH':'mm':'ss zz00"); } else { this.parameters.Remove("modification-date"); } } } /// Gets the parameters included in the Content-Disposition header represented by this instance. /// A writable that contains parameter name/value pairs. // Token: 0x170002E0 RID: 736 // (get) Token: 0x06000B79 RID: 2937 RVA: 0x00023324 File Offset: 0x00021524 public global::System.Collections.Specialized.StringDictionary Parameters { get { return this.parameters; } } /// Gets or sets the read date for a file attachment. /// A value that indicates the file read date; otherwise, if no date was specified. // Token: 0x170002E1 RID: 737 // (get) Token: 0x06000B7A RID: 2938 RVA: 0x0002332C File Offset: 0x0002152C // (set) Token: 0x06000B7B RID: 2939 RVA: 0x00023370 File Offset: 0x00021570 public DateTime ReadDate { get { if (this.parameters.ContainsKey("read-date")) { return DateTime.ParseExact(this.parameters["read-date"], "dd MMM yyyy HH':'mm':'ss zz00", null); } return DateTime.MinValue; } set { if (value > DateTime.MinValue) { this.parameters["read-date"] = value.ToString("dd MMM yyyy HH':'mm':'ss zz00"); } else { this.parameters.Remove("read-date"); } } } /// Gets or sets the size of a file attachment. /// A that specifies the number of bytes in the file attachment. The default value is -1, which indicates that the file size is unknown. // Token: 0x170002E2 RID: 738 // (get) Token: 0x06000B7C RID: 2940 RVA: 0x000233C0 File Offset: 0x000215C0 // (set) Token: 0x06000B7D RID: 2941 RVA: 0x000233F0 File Offset: 0x000215F0 public long Size { get { if (this.parameters.ContainsKey("size")) { return long.Parse(this.parameters["size"]); } return -1L; } set { if (value > -1L) { this.parameters["size"] = value.ToString(); } else { this.parameters.Remove("size"); } } } /// Determines whether the content-disposition header of the specified object is equal to the content-disposition header of this object. /// true if the content-disposition headers are the same; otherwise false. /// The object to compare with this object. // Token: 0x06000B7E RID: 2942 RVA: 0x00023434 File Offset: 0x00021634 public override bool Equals(object obj) { return this.Equals(obj as ContentDisposition); } // Token: 0x06000B7F RID: 2943 RVA: 0x00023444 File Offset: 0x00021644 private bool Equals(ContentDisposition other) { return other != null && this.ToString() == other.ToString(); } /// Determines the hash code of the specified object /// An integer hash value. // Token: 0x06000B80 RID: 2944 RVA: 0x00023460 File Offset: 0x00021660 public override int GetHashCode() { return this.ToString().GetHashCode(); } /// Returns a representation of this instance. /// A that contains the property values for this instance. // Token: 0x06000B81 RID: 2945 RVA: 0x00023470 File Offset: 0x00021670 public override string ToString() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(this.DispositionType.ToLower()); if (this.Parameters != null && this.Parameters.Count > 0) { foreach (object obj in this.Parameters) { DictionaryEntry dictionaryEntry = (DictionaryEntry)obj; if (dictionaryEntry.Value != null && dictionaryEntry.Value.ToString().Length > 0) { stringBuilder.Append("; "); stringBuilder.Append(dictionaryEntry.Key); stringBuilder.Append("="); string text = dictionaryEntry.Key.ToString(); string text2 = dictionaryEntry.Value.ToString(); bool flag = (text == "filename" && text2.IndexOf(' ') != -1) || text.EndsWith("date"); if (flag) { stringBuilder.Append("\""); } stringBuilder.Append(text2); if (flag) { stringBuilder.Append("\""); } } } } return stringBuilder.ToString(); } // Token: 0x04000B74 RID: 2932 private const string rfc822 = "dd MMM yyyy HH':'mm':'ss zz00"; // Token: 0x04000B75 RID: 2933 private string dispositionType; // Token: 0x04000B76 RID: 2934 private global::System.Collections.Specialized.StringDictionary parameters = new global::System.Collections.Specialized.StringDictionary(); } }