Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Net / System / Net / Mail / HeaderCollection.cs / 3 / HeaderCollection.cs
using System; using System.Collections.Specialized; using System.Net.Mail; using System.Globalization; namespace System.Net.Mime { ////// Summary description for HeaderCollection. /// internal class HeaderCollection: NameValueCollection { MimeBasePart part = null; // default constructor // intentionally override the default comparer in the derived base class internal HeaderCollection() : base(StringComparer.OrdinalIgnoreCase) { } public override void Remove(string name) { if(Logging.On)Logging.PrintInfo(Logging.Web, this, "Remove", name); if (name == null) throw new ArgumentNullException("name"); if (name == string.Empty) throw new ArgumentException(SR.GetString(SR.net_emptystringcall,"name"), "name"); MailHeaderID id = MailHeaderInfo.GetID(name); if (id == MailHeaderID.ContentType && part != null) { part.ContentType = null; } else if (id == MailHeaderID.ContentDisposition && part is MimePart) { ((MimePart)part).ContentDisposition = null; } base.Remove(name); } public override string Get(string name) { if(Logging.On)Logging.PrintInfo(Logging.Web, this, "Get", name); if (name == null) throw new ArgumentNullException("name"); if (name == string.Empty) throw new ArgumentException(SR.GetString(SR.net_emptystringcall,"name"), "name"); MailHeaderID id = MailHeaderInfo.GetID(name); if (id == MailHeaderID.ContentType && part != null) { part.ContentType.PersistIfNeeded(this,false); } else if (id == MailHeaderID.ContentDisposition && part is MimePart) { ((MimePart)part).ContentDisposition.PersistIfNeeded(this, false); } return base.Get(name); } public override string[] GetValues(string name) { if(Logging.On)Logging.PrintInfo(Logging.Web, this, "Get", name); if (name == null) throw new ArgumentNullException("name"); if (name == string.Empty) throw new ArgumentException(SR.GetString(SR.net_emptystringcall,"name"), "name"); MailHeaderID id = MailHeaderInfo.GetID(name); if (id == MailHeaderID.ContentType && part != null) { part.ContentType.PersistIfNeeded(this,false); } else if (id == MailHeaderID.ContentDisposition && part is MimePart) { ((MimePart)part).ContentDisposition.PersistIfNeeded(this, false); } return base.GetValues(name); } internal void InternalRemove(string name){ base.Remove(name); } internal void InternalSet(string name, string value) { base.Set(name, value); } public override void Set(string name, string value) { if(Logging.On)Logging.PrintInfo(Logging.Web, this, "Set", name.ToString() + "=" + value.ToString()); if (name == null) throw new ArgumentNullException("name"); if (value == null) throw new ArgumentNullException("value"); if (name == string.Empty) throw new ArgumentException(SR.GetString(SR.net_emptystringcall,"name"), "name"); if (value == string.Empty) throw new ArgumentException(SR.GetString(SR.net_emptystringcall,"value"), "name"); if (!MimeBasePart.IsAscii(name,false)) { throw new FormatException(SR.GetString(SR.InvalidHeaderName)); } if (!MimeBasePart.IsAnsi(value,false)) { throw new FormatException(SR.GetString(SR.InvalidHeaderValue)); } // normalize the case of well known headers name = MailHeaderInfo.NormalizeCase(name); MailHeaderID id = MailHeaderInfo.GetID(name); if (id == MailHeaderID.ContentType && part != null) { part.ContentType.Set(value.ToLower(CultureInfo.InvariantCulture), this); } else if (id == MailHeaderID.ContentDisposition && part is MimePart) { ((MimePart)part).ContentDisposition.Set(value.ToLower(CultureInfo.InvariantCulture), this); } else { base.Set(name, value); } } public override void Add(string name, string value) { if(Logging.On)Logging.PrintInfo(Logging.Web, this, "Add", name.ToString() + "=" + value.ToString()); if (name == null) throw new ArgumentNullException("name"); if (value == null) throw new ArgumentNullException("value"); if (name == string.Empty) throw new ArgumentException(SR.GetString(SR.net_emptystringcall,"name"), "name"); if (value == string.Empty) throw new ArgumentException(SR.GetString(SR.net_emptystringcall,"value"), "name"); MailBnfHelper.ValidateHeaderName(name); if (!MimeBasePart.IsAnsi(value,false)) { throw new FormatException(SR.GetString(SR.InvalidHeaderValue)); } // normalize the case of well known headers name = MailHeaderInfo.NormalizeCase(name); MailHeaderID id = MailHeaderInfo.GetID(name); if(id == MailHeaderID.ContentType && part != null) { part.ContentType.Set(value.ToLower(CultureInfo.InvariantCulture), this); } else if (id == MailHeaderID.ContentDisposition && part is MimePart) { ((MimePart)part).ContentDisposition.Set(value.ToLower(CultureInfo.InvariantCulture), this); } else { if (MailHeaderInfo.IsSingleton(name)) { base.Set(name, value); } else { base.Add(name, value); } } } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DefaultMemberAttribute.cs
- ResXResourceSet.cs
- ListBoxItemAutomationPeer.cs
- ADMembershipProvider.cs
- PreDigestedSignedInfo.cs
- ExtentCqlBlock.cs
- Literal.cs
- ParamArrayAttribute.cs
- LocalBuilder.cs
- DesignOnlyAttribute.cs
- SecurityTokenException.cs
- GlyphElement.cs
- LogConverter.cs
- StylusCollection.cs
- CurrencyManager.cs
- SystemTcpStatistics.cs
- RoleGroupCollection.cs
- OdbcCommandBuilder.cs
- UriTemplatePathSegment.cs
- DataListItemCollection.cs
- UnsafeNativeMethods.cs
- BinaryNegotiation.cs
- FixedSOMSemanticBox.cs
- UInt32Converter.cs
- DefaultExpressionVisitor.cs
- DefaultValueConverter.cs
- EntityDataSourceContextCreatedEventArgs.cs
- LocalValueEnumerator.cs
- DispatcherTimer.cs
- ToolStripDropDownClosingEventArgs.cs
- InputChannelBinder.cs
- X509AsymmetricSecurityKey.cs
- DerivedKeySecurityTokenStub.cs
- CommandValueSerializer.cs
- ComponentChangedEvent.cs
- EventManager.cs
- GeneralTransform.cs
- DbParameterCollectionHelper.cs
- SQLConvert.cs
- EditableRegion.cs
- HttpInputStream.cs
- DataTransferEventArgs.cs
- Substitution.cs
- ToolStrip.cs
- TypeForwardedToAttribute.cs
- DataGridAutoFormatDialog.cs
- datacache.cs
- BoundPropertyEntry.cs
- DispatcherHooks.cs
- ImageListStreamer.cs
- PrintDialog.cs
- DataTableNewRowEvent.cs
- HelloMessage11.cs
- LabelAutomationPeer.cs
- Tool.cs
- AdRotator.cs
- WindowsGraphicsWrapper.cs
- PingReply.cs
- LinearGradientBrush.cs
- CacheRequest.cs
- MeasureData.cs
- X509CertificateValidator.cs
- IPipelineRuntime.cs
- FileLevelControlBuilderAttribute.cs
- SequenceDesignerAccessibleObject.cs
- AnimatedTypeHelpers.cs
- RoleGroupCollection.cs
- XmlSchemaGroupRef.cs
- CodeTypeMember.cs
- GeneralTransform2DTo3DTo2D.cs
- TextParagraphProperties.cs
- SymbolEqualComparer.cs
- XamlReaderHelper.cs
- InstanceKey.cs
- MessageContractImporter.cs
- SecurityException.cs
- EndOfStreamException.cs
- Token.cs
- StreamUpgradeProvider.cs
- PeerToPeerException.cs
- StreamUpdate.cs
- Mouse.cs
- linebase.cs
- streamingZipPartStream.cs
- PreProcessor.cs
- SiteMapProvider.cs
- IImplicitResourceProvider.cs
- SocketElement.cs
- BufferedGraphicsManager.cs
- StatusStrip.cs
- SettingsContext.cs
- ZoneIdentityPermission.cs
- UnsafeNativeMethods.cs
- CommonObjectSecurity.cs
- CapabilitiesAssignment.cs
- DecodeHelper.cs
- XsdBuilder.cs
- ClientFormsIdentity.cs
- ImageFormat.cs
- CellNormalizer.cs