C# Class sidepop.Mime.MimeReader

This class is responsible for parsing a string array of lines containing a MIME message.
ファイルを表示 Open project: Octopus-ITSM/sidepop Class Usage Examples

Public Methods

Method Description
CreateMimeEntity ( ) : MimeEntity

Creates the MIME entity.

GetContentDisposition ( string contentDisposition ) : ContentDisposition

Get the content disposition parsed from the specified string

GetContentType ( string contentType, bool throwOnInvalidContentType = false ) : ContentType

Gets the type of the content.

GetMediaMainType ( string mediaType ) : string

Gets the type of the media main.

GetMediaSubType ( string mediaType ) : string

Gets the type of the media sub.

GetMediaType ( string mediaType ) : string

Gets the type of the media.

GetTransferEncoding ( string transferEncoding ) : TransferEncoding

Gets the transfer encoding.

The transfer encoding determination follows the same rules as Peter Huber's article w/ the exception of not throwing exceptions when binary is provided as a transferEncoding. Instead it is left to the calling code to check for binary.

MimeReader ( byte rawBytes, bool throwOnInvalidContentType = false ) : System

Initializes a new instance of the MimeReader class.

SplitByteArrayWithCrLf ( byte byteArray ) : byte[][]

Splits a byte array using CrLf as the line delimiter.

Private Methods

Method Description
AddChildEntity ( MimeEntity entity, Queue lines ) : void

Adds the child entity.

AppendMessageContent ( ) : void

Append the current queued line to the entity encoded / decoded message buffers

ConvertBytesToStringWithDefaultEncoding ( byte line ) : string

Converts bytes using the default encoding

DecodePartIfNeeded ( MimeEntity parentEntity, Queue lines ) : Queue

Decodes the specified part if needed.

Dequeue ( ) : byte[]

Consumes a line and add it to the raw content of this mime part.

FixUnquotedEncodedString ( string value ) : string

Ensure that a value representing a encoded value is surrounded with double quotes

GetBytes ( string content ) : byte[]

Gets a byte[] of content for the provided string.

HasReachParentBoundary ( string line ) : bool

Returns whether the current line matches the parent boundary

HasReachedEndOfPart ( ) : bool

Returns whether the current line is the end of a part.

IsInvalidDateTime ( string dateValueString ) : bool

Returns whether the specified string represents a valid date time.

MimeReader ( ) : System

Static Ctor

MimeReader ( MimeEntity entity, Queue lines, bool throwOnInvalidContentType ) : System

Initializes a new instance of the MimeReader class.

MimeReader ( bool throwOnInvalidContentType ) : System

Initializes a new instance of the MimeReader class.

ParseBody ( ) : void

Parses the body.

ParseHeaders ( ) : int

Parse headers into _entity.Headers NameValueCollection.

ProcessHeaders ( ) : void

Processes mime specific headers.

ReadPart ( ) : Queue

Reads all the lines of the current part.

RemoveIfInvalidDateTime ( string contentDisposition, string dateTokenName ) : string

Parse for the received token, and if found, try to parse the date. If it fails, remove the whole token from the line

StripInvalidDateTime ( string contentDisposition ) : string

Remove any invalid date. Some client, like NOVEL_GROUPWISE store invalid date, such as Thu, 19 sep 2012. In 2012, September 19 was a wednesday

Method Details

CreateMimeEntity() public method

Creates the MIME entity.
public CreateMimeEntity ( ) : MimeEntity
return MimeEntity

GetContentDisposition() public static method

Get the content disposition parsed from the specified string
public static GetContentDisposition ( string contentDisposition ) : ContentDisposition
contentDisposition string
return System.Net.Mime.ContentDisposition

GetContentType() public static method

Gets the type of the content.
public static GetContentType ( string contentType, bool throwOnInvalidContentType = false ) : ContentType
contentType string Type of the content.
throwOnInvalidContentType bool
return System.Net.Mime.ContentType

GetMediaMainType() public static method

Gets the type of the media main.
public static GetMediaMainType ( string mediaType ) : string
mediaType string Type of the media.
return string

GetMediaSubType() public static method

Gets the type of the media sub.
public static GetMediaSubType ( string mediaType ) : string
mediaType string Type of the media.
return string

GetMediaType() public static method

Gets the type of the media.
public static GetMediaType ( string mediaType ) : string
mediaType string Type of the media.
return string

GetTransferEncoding() public static method

Gets the transfer encoding.
The transfer encoding determination follows the same rules as Peter Huber's article w/ the exception of not throwing exceptions when binary is provided as a transferEncoding. Instead it is left to the calling code to check for binary.
public static GetTransferEncoding ( string transferEncoding ) : TransferEncoding
transferEncoding string The transfer encoding.
return TransferEncoding

MimeReader() public method

Initializes a new instance of the MimeReader class.
public MimeReader ( byte rawBytes, bool throwOnInvalidContentType = false ) : System
rawBytes byte The raw bytes of the message.
throwOnInvalidContentType bool Determine if an invalid content type should raise an exception.
return System

SplitByteArrayWithCrLf() public static method

Splits a byte array using CrLf as the line delimiter.
public static SplitByteArrayWithCrLf ( byte byteArray ) : byte[][]
byteArray byte
return byte[][]