using System;
using System.Collections.Generic;
using System.Text;
namespace MailServer.Misc.MIME
{
///
/// This class represent header field what parsing has failed.
///
public class MIME_h_Unparsed : MIME_h
{
private string m_ParseValue = null;
private string m_Name = null;
private string m_Value = null;
private Exception m_pException = null;
///
/// Default constructor.
///
/// Header field value. Header field name must be included. For example: 'Content-Type: text/plain'.
/// Parsing error.
/// Is raised when value is null reference.
/// Is raised when header field parsing errors.
internal MIME_h_Unparsed(string value,Exception exception)
{
if(value == null){
throw new ArgumentNullException("value");
}
string[] name_value = value.Split(new char[]{':'},2);
if(name_value.Length != 2){
throw new ParseException("Invalid Content-Type: header field value '" + value + "'.");
}
m_Name = name_value[0];
m_Value = name_value[1].Trim();
m_ParseValue = value;
m_pException = exception;
}
#region static method Parse
///
/// Parses header field from the specified value.
///
/// Header field value. Header field name must be included. For example: 'Content-Type: text/plain'.
/// Returns parsed header field.
/// Is alwyas raised when this mewthod is accsessed.
public static MIME_h_Unparsed Parse(string value)
{
throw new InvalidOperationException();
}
#endregion
#region override method ToString
///
/// Returns header field as string.
///
/// 8-bit words ecnoder. Value null means that words are not encoded.
/// Charset to use to encode 8-bit characters. Value null means parameters not encoded.
/// Returns header field as string.
public override string ToString(MIME_Encoding_EncodedWord wordEncoder,Encoding parmetersCharset)
{
return m_ParseValue;
}
#endregion
#region Properties implementation
///
/// Gets if this header field is modified since it has loaded.
///
/// All new added header fields has IsModified = true.
/// Is riased when this class is disposed and this property is accessed.
public override bool IsModified
{
get{ return false; }
}
///
/// Gets header field name.
///
public override string Name
{
get { return m_Name; }
}
///
/// Gets header field value.
///
public string Value
{
get{ return m_Value; }
}
///
/// Gets error happened during parse.
///
public Exception Exception
{
get{ return m_pException; }
}
#endregion
}
}