private void ParseValue()
 {
     if (this.parameters == null)
     {
         int offset = 0;
         this.parameters = new Dictionary <string, string>();
         this.mediaType  = MailBnfHelper.ReadToken(base.Value, ref offset, null);
         if ((offset >= base.Value.Length) || (base.Value[offset++] != '/'))
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(System.Runtime.Serialization.SR.GetString("MimeContentTypeHeaderInvalid")));
         }
         this.subType = MailBnfHelper.ReadToken(base.Value, ref offset, null);
         while (MailBnfHelper.SkipCFWS(base.Value, ref offset))
         {
             if ((offset >= base.Value.Length) || (base.Value[offset++] != ';'))
             {
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(System.Runtime.Serialization.SR.GetString("MimeContentTypeHeaderInvalid")));
             }
             if (!MailBnfHelper.SkipCFWS(base.Value, ref offset))
             {
                 break;
             }
             string str = MailBnfHelper.ReadParameterAttribute(base.Value, ref offset, null);
             if (((str == null) || (offset >= base.Value.Length)) || (base.Value[offset++] != '='))
             {
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(System.Runtime.Serialization.SR.GetString("MimeContentTypeHeaderInvalid")));
             }
             string str2 = MailBnfHelper.ReadParameterValue(base.Value, ref offset, null);
             this.parameters.Add(str.ToLowerInvariant(), str2);
         }
         if (this.parameters.ContainsKey(MtomGlobals.StartInfoParam))
         {
             string data  = this.parameters[MtomGlobals.StartInfoParam];
             int    index = data.IndexOf(';');
             if (index > -1)
             {
                 while (MailBnfHelper.SkipCFWS(data, ref index))
                 {
                     if (data[index] != ';')
                     {
                         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(System.Runtime.Serialization.SR.GetString("MimeContentTypeHeaderInvalid")));
                     }
                     index++;
                     string str4 = MailBnfHelper.ReadParameterAttribute(data, ref index, null);
                     if (((str4 == null) || (index >= data.Length)) || (data[index++] != '='))
                     {
                         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(System.Runtime.Serialization.SR.GetString("MimeContentTypeHeaderInvalid")));
                     }
                     string str5 = MailBnfHelper.ReadParameterValue(data, ref index, null);
                     if (str4 == MtomGlobals.ActionParam)
                     {
                         this.parameters[MtomGlobals.ActionParam] = str5;
                     }
                 }
             }
         }
     }
 }
Beispiel #2
0
 private void ParseValue()
 {
     if (base.Value == "1.0")
     {
         this.version = "1.0";
     }
     else
     {
         int offset = 0;
         if (!MailBnfHelper.SkipCFWS(base.Value, ref offset))
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(System.Runtime.Serialization.SR.GetString("MimeVersionHeaderInvalid")));
         }
         StringBuilder builder = new StringBuilder();
         MailBnfHelper.ReadDigits(base.Value, ref offset, builder);
         if ((!MailBnfHelper.SkipCFWS(base.Value, ref offset) || (offset >= base.Value.Length)) || ((base.Value[offset++] != '.') || !MailBnfHelper.SkipCFWS(base.Value, ref offset)))
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(System.Runtime.Serialization.SR.GetString("MimeVersionHeaderInvalid")));
         }
         builder.Append('.');
         MailBnfHelper.ReadDigits(base.Value, ref offset, builder);
         this.version = builder.ToString();
     }
 }