Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / Net / System / Net / Mail / HeaderCollection.cs / 1 / 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); } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. 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); } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- InstancePersistenceCommand.cs
- AxHostDesigner.cs
- SemaphoreSecurity.cs
- EntityDesignerBuildProvider.cs
- _Semaphore.cs
- HyperLink.cs
- SecurityKeyIdentifierClause.cs
- GenericTypeParameterBuilder.cs
- FontStyle.cs
- OleDbRowUpdatingEvent.cs
- GlobalizationAssembly.cs
- lengthconverter.cs
- LocatorGroup.cs
- XhtmlBasicPageAdapter.cs
- OpenTypeCommon.cs
- XmlAnyElementAttribute.cs
- WSFederationHttpBindingElement.cs
- ShaderEffect.cs
- MenuStrip.cs
- KnownTypesHelper.cs
- RegistryPermission.cs
- Metadata.cs
- WebRequestModuleElementCollection.cs
- CorrelationResolver.cs
- QilNode.cs
- TemplatePagerField.cs
- ObjectViewEntityCollectionData.cs
- DesignUtil.cs
- ValidatedControlConverter.cs
- AccessDataSourceView.cs
- ColumnTypeConverter.cs
- ITreeGenerator.cs
- UITypeEditor.cs
- ConfigurationSection.cs
- XamlParser.cs
- HTMLTagNameToTypeMapper.cs
- TabControlAutomationPeer.cs
- SystemException.cs
- Messages.cs
- BitmapEffectCollection.cs
- InternalConfigEventArgs.cs
- XPathExpr.cs
- StateMachineHistory.cs
- SqlDataReaderSmi.cs
- XmlSiteMapProvider.cs
- BindingExpressionUncommonField.cs
- XmlBufferedByteStreamReader.cs
- XMLSyntaxException.cs
- FontUnit.cs
- OleDbTransaction.cs
- RegexMatchCollection.cs
- PerformanceCounter.cs
- HMACSHA256.cs
- UpdateProgress.cs
- BitmapEffectGeneralTransform.cs
- HostSecurityManager.cs
- WebPartConnectVerb.cs
- ListViewTableCell.cs
- HighlightVisual.cs
- GeneralTransformGroup.cs
- Relationship.cs
- IArgumentProvider.cs
- MappedMetaModel.cs
- HierarchicalDataSourceControl.cs
- Console.cs
- SqlUtils.cs
- Stack.cs
- RenderDataDrawingContext.cs
- Rect3DValueSerializer.cs
- PathGeometry.cs
- loginstatus.cs
- ExpressionParser.cs
- WebSysDisplayNameAttribute.cs
- BinaryExpression.cs
- StatusBarDesigner.cs
- EntityDesignerBuildProvider.cs
- UTF8Encoding.cs
- StandardTransformFactory.cs
- FusionWrap.cs
- StrongNamePublicKeyBlob.cs
- MessageBox.cs
- FontInfo.cs
- Viewport2DVisual3D.cs
- FunctionParameter.cs
- FormViewInsertedEventArgs.cs
- WebPartsPersonalization.cs
- Tokenizer.cs
- RootBrowserWindowAutomationPeer.cs
- TypeSchema.cs
- WebBrowserProgressChangedEventHandler.cs
- BitmapMetadataBlob.cs
- _Semaphore.cs
- ToolboxBitmapAttribute.cs
- Helpers.cs
- EventLogEntry.cs
- WebPartConnectionsCancelEventArgs.cs
- SettingsPropertyIsReadOnlyException.cs
- DBPropSet.cs
- Encoder.cs
- TypeKeyValue.cs