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
- Int16Storage.cs
- HandlerMappingMemo.cs
- Visual3DCollection.cs
- DiagnosticsConfiguration.cs
- CollectionDataContractAttribute.cs
- GeneralTransform3D.cs
- BinaryNode.cs
- PersianCalendar.cs
- EventEntry.cs
- InputBindingCollection.cs
- RelatedCurrencyManager.cs
- ItemList.cs
- ImageBrush.cs
- path.cs
- FolderBrowserDialog.cs
- StatusBarDrawItemEvent.cs
- RequestCachePolicy.cs
- HttpDebugHandler.cs
- ObjectAnimationBase.cs
- TrackingLocationCollection.cs
- TypeToken.cs
- TraceProvider.cs
- SystemEvents.cs
- ConfigViewGenerator.cs
- BlurEffect.cs
- oledbmetadatacolumnnames.cs
- UICuesEvent.cs
- XmlLoader.cs
- FlowLayoutSettings.cs
- TextEffectResolver.cs
- DbParameterHelper.cs
- EventManager.cs
- LogReservationCollection.cs
- GraphicsContainer.cs
- TdsEnums.cs
- TextBoxView.cs
- HtmlInputPassword.cs
- XDeferredAxisSource.cs
- Version.cs
- PeerNearMe.cs
- VerifyHashRequest.cs
- ColorAnimationBase.cs
- InternalConfigEventArgs.cs
- OleDbParameter.cs
- DataListDesigner.cs
- ColorAnimation.cs
- CodeTypeReferenceCollection.cs
- StylusEditingBehavior.cs
- MemoryRecordBuffer.cs
- SchemaImporterExtension.cs
- TextWriter.cs
- CallInfo.cs
- LineVisual.cs
- ImpersonationContext.cs
- WorkItem.cs
- SHA256Cng.cs
- Paragraph.cs
- ValueTypeFixupInfo.cs
- DataGridViewTextBoxColumn.cs
- safelinkcollection.cs
- ConnectionPointGlyph.cs
- ColumnCollection.cs
- SHA384CryptoServiceProvider.cs
- XmlAttributeOverrides.cs
- CompilerGlobalScopeAttribute.cs
- WebPartDisplayModeCancelEventArgs.cs
- FrameworkRichTextComposition.cs
- BitSet.cs
- ZeroOpNode.cs
- AssemblyAttributesGoHere.cs
- SimpleHandlerBuildProvider.cs
- WindowsGraphics.cs
- TableRowCollection.cs
- CompModSwitches.cs
- HostedTcpTransportManager.cs
- EndpointReference.cs
- RealProxy.cs
- Typeface.cs
- EventProviderWriter.cs
- ExtendedTransformFactory.cs
- WinEventTracker.cs
- ProbeMatchesMessage11.cs
- CompileXomlTask.cs
- HtmlTable.cs
- XmlNodeList.cs
- FormsAuthentication.cs
- SessionIDManager.cs
- TemplateControlBuildProvider.cs
- ExpressionContext.cs
- HandlerFactoryCache.cs
- AssemblyBuilderData.cs
- ToolStripContainer.cs
- SatelliteContractVersionAttribute.cs
- DrawListViewColumnHeaderEventArgs.cs
- CodeDelegateCreateExpression.cs
- ClassicBorderDecorator.cs
- RolePrincipal.cs
- HtmlControlPersistable.cs
- MSG.cs
- ArglessEventHandlerProxy.cs