private void ParseValue() { int num = 0; try { _dispositionType = MailBnfHelper.ReadToken(_disposition, ref num, null); if (string.IsNullOrEmpty(_dispositionType)) { throw new FormatException(); } if (_parameters == null) { _parameters = new Dictionary <string, string>(); } else { _parameters.Clear(); } while (MailBnfHelper.SkipCfWs(_disposition, ref num)) { if (_disposition[num++] != ';') { throw new FormatException(); } if (!MailBnfHelper.SkipCfWs(_disposition, ref num)) { break; } string text = MailBnfHelper.ReadParameterAttribute(_disposition, ref num, null); if (_disposition[num++] != '=') { throw new FormatException(); } if (!MailBnfHelper.SkipCfWs(_disposition, ref num)) { throw new FormatException(); } string value = _disposition[num] == '"' ? MailBnfHelper.ReadQuotedString(_disposition, ref num, null) : MailBnfHelper.ReadToken(_disposition, ref num, null); if (string.IsNullOrEmpty(text) || string.IsNullOrEmpty(value)) { throw new FormatException(); } Parameters.Add(text, value); } } catch (FormatException innerException) { throw new FormatException(); } }
private void ParseValue() { int num = 0; Exception ex = null; _parameters = new Dictionary <string, string>(); try { _mediaType = MailBnfHelper.ReadToken(_type, ref num, null); if (string.IsNullOrEmpty(_mediaType) || num >= _type.Length || _type[num++] != '/') { ex = new FormatException(); } if (ex == null) { _subType = MailBnfHelper.ReadToken(_type, ref num, null); if (string.IsNullOrEmpty(_subType)) { ex = new FormatException(); } } if (ex == null) { while (MailBnfHelper.SkipCfWs(_type, ref num)) { if (_type[num++] != ';') { ex = new FormatException(); break; } if (!MailBnfHelper.SkipCfWs(_type, ref num)) { break; } string text = MailBnfHelper.ReadParameterAttribute(_type, ref num, null); if (string.IsNullOrEmpty(text)) { ex = new FormatException(); break; } if (num >= _type.Length || _type[num++] != '=') { ex = new FormatException(); break; } if (!MailBnfHelper.SkipCfWs(_type, ref num)) { ex = new FormatException(); break; } string text2 = _type[num] == '"' ? MailBnfHelper.ReadQuotedString(_type, ref num, null) : MailBnfHelper.ReadToken(_type, ref num, null); if (text2 == null) { ex = new FormatException(); break; } _parameters.Add(text, text2); } } } catch (FormatException) { throw new FormatException(); } if (ex != null) { throw new FormatException(); } }