/// <summary> /// Called when the headers change in some way. /// </summary> /// <remarks> /// Updates the <see cref="ContentTransferEncoding"/>, <see cref="ContentDuration"/>, /// and <see cref="ContentMd5"/> properties if the corresponding headers have changed. /// </remarks> /// <param name="action">The type of change.</param> /// <param name="header">The header being added, changed or removed.</param> protected override void OnHeadersChanged(HeaderListChangedAction action, Header header) { int value; base.OnHeadersChanged(action, header); switch (action) { case HeaderListChangedAction.Added: case HeaderListChangedAction.Changed: switch (header.Id) { case HeaderId.ContentTransferEncoding: MimeUtils.TryParse(header.Value, out encoding); break; case HeaderId.ContentDuration: if (int.TryParse(header.Value, out value)) { duration = value; } else { duration = null; } break; case HeaderId.ContentMd5: md5sum = header.Value.Trim(); break; } break; case HeaderListChangedAction.Removed: switch (header.Id) { case HeaderId.ContentTransferEncoding: encoding = ContentEncoding.Default; break; case HeaderId.ContentDuration: duration = null; break; case HeaderId.ContentMd5: md5sum = null; break; } break; case HeaderListChangedAction.Cleared: encoding = ContentEncoding.Default; duration = null; md5sum = null; break; default: throw new ArgumentOutOfRangeException(nameof(action)); } }
void OnChanged(Header header, HeaderListChangedAction action) { if (Changed != null) { Changed(this, new HeaderListChangedEventArgs(header, action)); } }
/// <summary> /// Called when the headers change in some way. /// </summary> /// <remarks> /// Whenever a header is changed, this method will be called in order to allow /// custom <see cref="MimeEntity"/> subclasses to update their state. /// </remarks> /// <param name="action">The type of change.</param> /// <param name="header">The header being added, changed or removed.</param> protected virtual void OnHeadersChanged(HeaderListChangedAction action, Header header) { switch (action) { case HeaderListChangedAction.Added: case HeaderListChangedAction.Changed: switch (header.Id) { case HeaderId.ContentDisposition: if (disposition != null) { disposition.Changed -= ContentDispositionChanged; } if (ContentDisposition.TryParse(Headers.Options, header.RawValue, out disposition)) { disposition.Changed += ContentDispositionChanged; } break; case HeaderId.ContentId: contentId = MimeUtils.EnumerateReferences(header.RawValue, 0, header.RawValue.Length).FirstOrDefault(); break; } break; case HeaderListChangedAction.Removed: switch (header.Id) { case HeaderId.ContentDisposition: if (disposition != null) { disposition.Changed -= ContentDispositionChanged; } disposition = null; break; case HeaderId.ContentId: contentId = null; break; } break; case HeaderListChangedAction.Cleared: if (disposition != null) { disposition.Changed -= ContentDispositionChanged; } disposition = null; contentId = null; break; default: throw new ArgumentOutOfRangeException("action"); } }
/// <summary> /// Called when the headers change in some way. /// </summary> /// <remarks> /// <para>Whenever a header is added, changed, or removed, this method will /// be called in order to allow custom <see cref="MimeEntity"/> subclasses /// to update their state.</para> /// <para>Overrides of this method should call the base method so that their /// superclass may also update its own state.</para> /// </remarks> /// <param name="action">The type of change.</param> /// <param name="header">The header being added, changed or removed.</param> protected virtual void OnHeadersChanged(HeaderListChangedAction action, Header header) { string text; switch (action) { case HeaderListChangedAction.Added: case HeaderListChangedAction.Changed: switch (header.Id) { case HeaderId.ContentDisposition: if (disposition != null) { disposition.Changed -= ContentDispositionChanged; } if (ContentDisposition.TryParse(Headers.Options, header.RawValue, out disposition)) { disposition.Changed += ContentDispositionChanged; } break; case HeaderId.ContentLocation: text = header.Value.Trim(); if (Uri.IsWellFormedUriString(text, UriKind.Absolute)) { location = new Uri(text, UriKind.Absolute); } else if (Uri.IsWellFormedUriString(text, UriKind.Relative)) { location = new Uri(text, UriKind.Relative); } else { location = null; } break; case HeaderId.ContentBase: text = header.Value.Trim(); if (Uri.IsWellFormedUriString(text, UriKind.Absolute)) { baseUri = new Uri(text, UriKind.Absolute); } else { baseUri = null; } break; case HeaderId.ContentId: contentId = MimeUtils.EnumerateReferences(header.RawValue, 0, header.RawValue.Length).FirstOrDefault(); break; } break; case HeaderListChangedAction.Removed: switch (header.Id) { case HeaderId.ContentDisposition: if (disposition != null) { disposition.Changed -= ContentDispositionChanged; } disposition = null; break; case HeaderId.ContentLocation: location = null; break; case HeaderId.ContentBase: baseUri = null; break; case HeaderId.ContentId: contentId = null; break; } break; case HeaderListChangedAction.Cleared: if (disposition != null) { disposition.Changed -= ContentDispositionChanged; } disposition = null; contentId = null; location = null; baseUri = null; break; default: throw new ArgumentOutOfRangeException("action"); } }
/// <summary> /// Called when the headers change in some way. /// </summary> /// <param name="action">The type of change.</param> /// <param name="header">The header being added, changed or removed.</param> protected override void OnHeadersChanged(HeaderListChangedAction action, Header header) { string text; int value; base.OnHeadersChanged(action, header); switch (action) { case HeaderListChangedAction.Added: case HeaderListChangedAction.Changed: switch (header.Id) { case HeaderId.ContentTransferEncoding: text = header.Value.Trim().ToLowerInvariant(); encoding = ContentEncoding.Default; for (int i = 1; i < ContentTransferEncodings.Length; i++) { if (ContentTransferEncodings[i] == text) { encoding = (ContentEncoding)i; break; } } break; case HeaderId.ContentDuration: if (int.TryParse(header.Value, out value)) { duration = value; } else { duration = null; } break; case HeaderId.ContentMd5: md5sum = header.Value.Trim(); break; } break; case HeaderListChangedAction.Removed: switch (header.Id) { case HeaderId.ContentTransferEncoding: encoding = ContentEncoding.Default; break; case HeaderId.ContentDuration: duration = null; break; case HeaderId.ContentMd5: md5sum = null; break; } break; case HeaderListChangedAction.Cleared: encoding = ContentEncoding.Default; duration = null; md5sum = null; break; default: throw new ArgumentOutOfRangeException(); } }
internal HeaderListChangedEventArgs(Header header, HeaderListChangedAction action) { Header = header; Action = action; }
/// <summary> /// Called when the headers change in some way. /// </summary> /// <remarks> /// Updates the <see cref="ContentTransferEncoding"/>, <see cref="ContentDuration"/>, /// and <see cref="ContentMd5"/> properties if the corresponding headers have changed. /// </remarks> /// <param name="action">The type of change.</param> /// <param name="header">The header being added, changed or removed.</param> protected override void OnHeadersChanged (HeaderListChangedAction action, Header header) { int value; base.OnHeadersChanged (action, header); switch (action) { case HeaderListChangedAction.Added: case HeaderListChangedAction.Changed: switch (header.Id) { case HeaderId.ContentTransferEncoding: MimeUtils.TryParse (header.Value, out encoding); break; case HeaderId.ContentDuration: if (int.TryParse (header.Value, out value)) duration = value; else duration = null; break; case HeaderId.ContentMd5: md5sum = header.Value.Trim (); break; } break; case HeaderListChangedAction.Removed: switch (header.Id) { case HeaderId.ContentTransferEncoding: encoding = ContentEncoding.Default; break; case HeaderId.ContentDuration: duration = null; break; case HeaderId.ContentMd5: md5sum = null; break; } break; case HeaderListChangedAction.Cleared: encoding = ContentEncoding.Default; duration = null; md5sum = null; break; default: throw new ArgumentOutOfRangeException ("action"); } }
/// <summary> /// Called when the headers change in some way. /// </summary> /// <remarks> /// <para>Whenever a header is added, changed, or removed, this method will /// be called in order to allow custom <see cref="MimeEntity"/> subclasses /// to update their state.</para> /// <para>Overrides of this method should call the base method so that their /// superclass may also update its own state.</para> /// </remarks> /// <param name="action">The type of change.</param> /// <param name="header">The header being added, changed or removed.</param> protected virtual void OnHeadersChanged (HeaderListChangedAction action, Header header) { string text; switch (action) { case HeaderListChangedAction.Added: case HeaderListChangedAction.Changed: switch (header.Id) { case HeaderId.ContentDisposition: if (disposition != null) disposition.Changed -= ContentDispositionChanged; if (ContentDisposition.TryParse (Headers.Options, header.RawValue, out disposition)) disposition.Changed += ContentDispositionChanged; break; case HeaderId.ContentLocation: text = header.Value.Trim (); if (Uri.IsWellFormedUriString (text, UriKind.Absolute)) location = new Uri (text, UriKind.Absolute); else if (Uri.IsWellFormedUriString (text, UriKind.Relative)) location = new Uri (text, UriKind.Relative); else location = null; break; case HeaderId.ContentBase: text = header.Value.Trim (); if (Uri.IsWellFormedUriString (text, UriKind.Absolute)) baseUri = new Uri (text, UriKind.Absolute); else baseUri = null; break; case HeaderId.ContentId: contentId = MimeUtils.EnumerateReferences (header.RawValue, 0, header.RawValue.Length).FirstOrDefault (); break; } break; case HeaderListChangedAction.Removed: switch (header.Id) { case HeaderId.ContentDisposition: if (disposition != null) disposition.Changed -= ContentDispositionChanged; disposition = null; break; case HeaderId.ContentLocation: location = null; break; case HeaderId.ContentBase: baseUri = null; break; case HeaderId.ContentId: contentId = null; break; } break; case HeaderListChangedAction.Cleared: if (disposition != null) disposition.Changed -= ContentDispositionChanged; disposition = null; contentId = null; location = null; baseUri = null; break; default: throw new ArgumentOutOfRangeException ("action"); } }
/// <summary> /// Called when the headers change in some way. /// </summary> /// <param name="action">The type of change.</param> /// <param name="header">The header being added, changed or removed.</param> protected override void OnHeadersChanged(HeaderListChangedAction action, Header header) { string text; int value; base.OnHeadersChanged(action, header); switch (action) { case HeaderListChangedAction.Added: case HeaderListChangedAction.Changed: switch (header.Id) { case HeaderId.ContentTransferEncoding: text = header.Value.Trim().ToLowerInvariant(); switch (text) { case "7bit": encoding = ContentEncoding.SevenBit; break; case "8bit": encoding = ContentEncoding.EightBit; break; case "binary": encoding = ContentEncoding.Binary; break; case "base64": encoding = ContentEncoding.Base64; break; case "quoted-printable": encoding = ContentEncoding.QuotedPrintable; break; case "x-uuencode": encoding = ContentEncoding.UUEncode; break; case "uuencode": encoding = ContentEncoding.UUEncode; break; default: encoding = ContentEncoding.Default; break; } break; case HeaderId.ContentDuration: if (int.TryParse(header.Value, out value)) { duration = value; } else { duration = null; } break; case HeaderId.ContentMd5: md5sum = header.Value.Trim(); break; } break; case HeaderListChangedAction.Removed: switch (header.Id) { case HeaderId.ContentTransferEncoding: encoding = ContentEncoding.Default; break; case HeaderId.ContentDuration: duration = null; break; case HeaderId.ContentMd5: md5sum = null; break; } break; case HeaderListChangedAction.Cleared: encoding = ContentEncoding.Default; duration = null; md5sum = null; break; default: throw new ArgumentOutOfRangeException("action"); } }
/// <summary> /// Called when the headers change in some way. /// </summary> /// <param name="action">The type of change.</param> /// <param name="header">The header being added, changed or removed.</param> protected virtual void OnHeadersChanged(HeaderListChangedAction action, Header header) { switch (action) { case HeaderListChangedAction.Added: case HeaderListChangedAction.Changed: switch (header.Id) { case HeaderId.ContentDisposition: if (disposition != null) disposition.Changed -= ContentDispositionChanged; if (ContentDisposition.TryParse (Headers.Options, header.RawValue, out disposition)) disposition.Changed += ContentDispositionChanged; break; case HeaderId.ContentId: contentId = MimeUtils.EnumerateReferences (header.RawValue, 0, header.RawValue.Length).FirstOrDefault (); break; } break; case HeaderListChangedAction.Removed: switch (header.Id) { case HeaderId.ContentDisposition: if (disposition != null) disposition.Changed -= ContentDispositionChanged; disposition = null; break; case HeaderId.ContentId: contentId = null; break; } break; case HeaderListChangedAction.Cleared: if (disposition != null) disposition.Changed -= ContentDispositionChanged; disposition = null; contentId = null; break; default: throw new ArgumentOutOfRangeException (); } }
internal HeaderListChangedEventArgs (Header header, HeaderListChangedAction action) { Header = header; Action = action; }
/// <summary> /// Called when the headers change in some way. /// </summary> /// <remarks> /// Updates the <see cref="ContentTransferEncoding"/>, <see cref="ContentDuration"/>, /// and <see cref="ContentMd5"/> properties if the corresponding headers have changed. /// </remarks> /// <param name="action">The type of change.</param> /// <param name="header">The header being added, changed or removed.</param> protected override void OnHeadersChanged (HeaderListChangedAction action, Header header) { string text; int value; base.OnHeadersChanged (action, header); switch (action) { case HeaderListChangedAction.Added: case HeaderListChangedAction.Changed: switch (header.Id) { case HeaderId.ContentTransferEncoding: text = header.Value.Trim ().ToLowerInvariant (); switch (text) { case "7bit": encoding = ContentEncoding.SevenBit; break; case "8bit": encoding = ContentEncoding.EightBit; break; case "binary": encoding = ContentEncoding.Binary; break; case "base64": encoding = ContentEncoding.Base64; break; case "quoted-printable": encoding = ContentEncoding.QuotedPrintable; break; case "x-uuencode": encoding = ContentEncoding.UUEncode; break; case "uuencode": encoding = ContentEncoding.UUEncode; break; default: encoding = ContentEncoding.Default; break; } break; case HeaderId.ContentDuration: if (int.TryParse (header.Value, out value)) duration = value; else duration = null; break; case HeaderId.ContentMd5: md5sum = header.Value.Trim (); break; } break; case HeaderListChangedAction.Removed: switch (header.Id) { case HeaderId.ContentTransferEncoding: encoding = ContentEncoding.Default; break; case HeaderId.ContentDuration: duration = null; break; case HeaderId.ContentMd5: md5sum = null; break; } break; case HeaderListChangedAction.Cleared: encoding = ContentEncoding.Default; duration = null; md5sum = null; break; default: throw new ArgumentOutOfRangeException ("action"); } }
/// <summary> /// Called when the headers change in some way. /// </summary> /// <remarks> /// <para>Whenever a header is added, changed, or removed, this method will /// be called in order to allow custom <see cref="MimeEntity"/> subclasses /// to update their state.</para> /// <para>Overrides of this method should call the base method so that their /// superclass may also update its own state.</para> /// </remarks> /// <param name="action">The type of change.</param> /// <param name="header">The header being added, changed or removed.</param> protected virtual void OnHeadersChanged (HeaderListChangedAction action, Header header) { MailboxAddress mailbox; int index = 0; string text; switch (action) { case HeaderListChangedAction.Added: case HeaderListChangedAction.Changed: switch (header.Id) { case HeaderId.ContentDisposition: if (disposition != null) disposition.Changed -= ContentDispositionChanged; if (ContentDisposition.TryParse (Headers.Options, header.RawValue, out disposition)) disposition.Changed += ContentDispositionChanged; break; case HeaderId.ContentLocation: text = header.Value.Trim (); if (Uri.IsWellFormedUriString (text, UriKind.Absolute)) location = new Uri (text, UriKind.Absolute); else if (Uri.IsWellFormedUriString (text, UriKind.Relative)) location = new Uri (text, UriKind.Relative); else location = null; break; case HeaderId.ContentBase: text = header.Value.Trim (); if (Uri.IsWellFormedUriString (text, UriKind.Absolute)) baseUri = new Uri (text, UriKind.Absolute); else baseUri = null; break; case HeaderId.ContentId: if (MailboxAddress.TryParse (Headers.Options, header.RawValue, ref index, header.RawValue.Length, false, out mailbox)) contentId = mailbox.Address; else contentId = null; break; } break; case HeaderListChangedAction.Removed: switch (header.Id) { case HeaderId.ContentDisposition: if (disposition != null) disposition.Changed -= ContentDispositionChanged; disposition = null; break; case HeaderId.ContentLocation: location = null; break; case HeaderId.ContentBase: baseUri = null; break; case HeaderId.ContentId: contentId = null; break; } break; case HeaderListChangedAction.Cleared: if (disposition != null) disposition.Changed -= ContentDispositionChanged; disposition = null; contentId = null; location = null; baseUri = null; break; default: throw new ArgumentOutOfRangeException (nameof (action)); } }
/// <summary> /// Called when the headers change in some way. /// </summary> /// <param name="action">The type of change.</param> /// <param name="header">The header being added, changed or removed.</param> protected override void OnHeadersChanged(HeaderListChangedAction action, Header header) { string text; int value; base.OnHeadersChanged (action, header); switch (action) { case HeaderListChangedAction.Added: case HeaderListChangedAction.Changed: switch (header.Id) { case HeaderId.ContentTransferEncoding: text = header.Value.Trim ().ToLowerInvariant (); encoding = ContentEncoding.Default; for (int i = 1; i < ContentTransferEncodings.Length; i++) { if (ContentTransferEncodings[i] == text) { encoding = (ContentEncoding) i; break; } } break; case HeaderId.ContentDuration: if (int.TryParse (header.Value, out value)) duration = value; else duration = null; break; case HeaderId.ContentMd5: md5sum = header.Value.Trim (); break; } break; case HeaderListChangedAction.Removed: switch (header.Id) { case HeaderId.ContentTransferEncoding: encoding = ContentEncoding.Default; break; case HeaderId.ContentDuration: duration = null; break; case HeaderId.ContentMd5: md5sum = null; break; } break; case HeaderListChangedAction.Cleared: encoding = ContentEncoding.Default; duration = null; md5sum = null; break; default: throw new ArgumentOutOfRangeException (); } }