Code:
/ FX-1434 / FX-1434 / 1.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
- SchemaComplexType.cs
- SetterBaseCollection.cs
- DBAsyncResult.cs
- SelectedGridItemChangedEvent.cs
- LinkUtilities.cs
- DataView.cs
- SemaphoreFullException.cs
- InertiaRotationBehavior.cs
- MessageSecurityOverTcp.cs
- ValidationSummary.cs
- AssociationTypeEmitter.cs
- Oid.cs
- CqlParser.cs
- EmptyQuery.cs
- XmlNodeWriter.cs
- PatternMatcher.cs
- ConfigurationProperty.cs
- SqlError.cs
- FunctionCommandText.cs
- StandardCommands.cs
- SafeViewOfFileHandle.cs
- ConfigurationValidatorAttribute.cs
- HMACSHA384.cs
- IIS7UserPrincipal.cs
- CompilerLocalReference.cs
- SoapException.cs
- WebHttpEndpoint.cs
- TrackBar.cs
- ObjectHandle.cs
- HttpProfileGroupBase.cs
- Lasso.cs
- WizardForm.cs
- SignatureToken.cs
- CodeMemberProperty.cs
- XmlIgnoreAttribute.cs
- Point3DAnimationBase.cs
- DesignerAttribute.cs
- ParallelRangeManager.cs
- AssemblyCollection.cs
- UIPermission.cs
- FixedSOMSemanticBox.cs
- GetImportedCardRequest.cs
- DataBinding.cs
- Site.cs
- SqlDataSourceConfigureFilterForm.cs
- RequestTimeoutManager.cs
- ContentValidator.cs
- NumberSubstitution.cs
- UIElementAutomationPeer.cs
- _CacheStreams.cs
- TypeContext.cs
- MetadataItemSerializer.cs
- DataGridTableCollection.cs
- SchemaCollectionPreprocessor.cs
- CfgRule.cs
- XamlDesignerSerializationManager.cs
- DataColumnMapping.cs
- WindowsToolbarAsMenu.cs
- ReflectTypeDescriptionProvider.cs
- GridViewHeaderRowPresenter.cs
- WindowsImpersonationContext.cs
- SqlUtil.cs
- Image.cs
- StringConverter.cs
- ChoiceConverter.cs
- CodeDomSerializerException.cs
- Nullable.cs
- SettingsPropertyWrongTypeException.cs
- Stylus.cs
- PersonalizationStateInfo.cs
- XmlNodeChangedEventManager.cs
- EntityDataSourceState.cs
- CustomValidator.cs
- ExternalException.cs
- MetafileEditor.cs
- TreeNodeStyle.cs
- MethodResolver.cs
- CollectionContainer.cs
- NavigationHelper.cs
- ALinqExpressionVisitor.cs
- LostFocusEventManager.cs
- QuotedPrintableStream.cs
- DesignerDataConnection.cs
- SqlXml.cs
- PackageProperties.cs
- PlainXmlDeserializer.cs
- TextChangedEventArgs.cs
- RoutedEventValueSerializer.cs
- ReflectTypeDescriptionProvider.cs
- InteropTrackingRecord.cs
- IntSecurity.cs
- ClientViaElement.cs
- PointLight.cs
- MouseBinding.cs
- Rect3D.cs
- ClientType.cs
- SmtpAuthenticationManager.cs
- CuspData.cs
- DbProviderFactoriesConfigurationHandler.cs
- ExportFileRequest.cs