Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MimeKit.Tnef.TnefReader"/> class.
        /// </summary>
        /// <remarks>
        /// <para>When reading a TNEF stream using the <see cref="TnefComplianceMode.Strict"/> mode,
        /// a <see cref="TnefException"/> will be thrown immediately at the first sign of
        /// invalid or corrupted data.</para>
        /// <para>When reading a TNEF stream using the <see cref="TnefComplianceMode.Loose"/> mode,
        /// however, compliance issues are accumulated in the <see cref="ComplianceMode"/>
        /// property, but exceptions are not raised unless the stream is too corrupted to continue.</para>
        /// </remarks>
        /// <param name="inputStream">The input stream.</param>
        /// <param name="defaultMessageCodepage">The default message codepage.</param>
        /// <param name="complianceMode">The compliance mode.</param>
        /// <exception cref="System.ArgumentNullException">
        /// <paramref name="inputStream"/> is <c>null</c>.
        /// </exception>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// <paramref name="defaultMessageCodepage"/> is not a valid codepage.
        /// </exception>
        /// <exception cref="System.NotSupportedException">
        /// <paramref name="defaultMessageCodepage"/> is not a supported codepage.
        /// </exception>
        /// <exception cref="TnefException">
        /// The TNEF stream is corrupted or invalid.
        /// </exception>
        public TnefReader(Stream inputStream, int defaultMessageCodepage, TnefComplianceMode complianceMode)
        {
            if (inputStream == null)
            {
                throw new ArgumentNullException("inputStream");
            }

            if (defaultMessageCodepage < 0)
            {
                throw new ArgumentOutOfRangeException("defaultMessageCodepage");
            }

            if (defaultMessageCodepage != 0)
            {
                // make sure that this codepage is valid...
                var encoding = Encoding.GetEncoding(defaultMessageCodepage);
                codepage = encoding.CodePage;
            }
            else
            {
                codepage = 1252;
            }

            TnefPropertyReader = new TnefPropertyReader(this);
            ComplianceMode     = complianceMode;
            InputStream        = inputStream;

            DecodeHeader();
        }
Exemplo n.º 2
0
		/// <summary>
		/// Initializes a new instance of the <see cref="MimeKit.Tnef.TnefReader"/> class.
		/// </summary>
		/// <remarks>
		/// <para>When reading a TNEF stream using the <see cref="TnefComplianceMode.Strict"/> mode,
		/// a <see cref="TnefException"/> will be thrown immediately at the first sign of
		/// invalid or corrupted data.</para>
		/// <para>When reading a TNEF stream using the <see cref="TnefComplianceMode.Loose"/> mode,
		/// however, compliance issues are accumulated in the <see cref="ComplianceMode"/>
		/// property, but exceptions are not raised unless the stream is too corrupted to continue.</para>
		/// </remarks>
		/// <param name="inputStream">The input stream.</param>
		/// <param name="defaultMessageCodepage">The default message codepage.</param>
		/// <param name="complianceMode">The compliance mode.</param>
		/// <exception cref="System.ArgumentNullException">
		/// <paramref name="inputStream"/> is <c>null</c>.
		/// </exception>
		/// <exception cref="System.ArgumentOutOfRangeException">
		/// <paramref name="defaultMessageCodepage"/> is not a valid codepage.
		/// </exception>
		/// <exception cref="System.NotSupportedException">
		/// <paramref name="defaultMessageCodepage"/> is not a supported codepage.
		/// </exception>
		/// <exception cref="TnefException">
		/// The TNEF stream is corrupted or invalid.
		/// </exception>
		public TnefReader (Stream inputStream, int defaultMessageCodepage, TnefComplianceMode complianceMode)
		{
			if (inputStream == null)
				throw new ArgumentNullException ("inputStream");

			if (defaultMessageCodepage < 0)
				throw new ArgumentOutOfRangeException ("defaultMessageCodepage");

			if (defaultMessageCodepage != 0) {
				// make sure that this codepage is valid...
				var encoding = Encoding.GetEncoding (defaultMessageCodepage);
				codepage = encoding.CodePage;
			} else {
				codepage = 1252;
			}

			TnefPropertyReader = new TnefPropertyReader (this);
			ComplianceMode = complianceMode;
			InputStream = inputStream;

			DecodeHeader ();
		}