Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Net / System / Net / Mail / MailAddressCollection.cs / 1305376 / MailAddressCollection.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Net.Mail { using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Text; using System.Net.Mime; public class MailAddressCollection: Collection{ public MailAddressCollection(){ } public void Add(string addresses) { if (addresses == null) { throw new ArgumentNullException("addresses"); } if (addresses == string.Empty) { throw new ArgumentException(SR.GetString(SR.net_emptystringcall, "addresses"), "addresses"); } ParseValue(addresses); } protected override void SetItem(int index, MailAddress item){ if(item==null) { throw new ArgumentNullException("item"); } base.SetItem(index,item); } protected override void InsertItem(int index, MailAddress item){ if(item==null){ throw new ArgumentNullException("item"); } base.InsertItem(index,item); } internal void ParseValue(string addresses){ IList result = MailAddressParser.ParseMultipleAddresses(addresses); for (int i = 0; i < result.Count; i++) { this.Add(result[i]); } } public override string ToString(){ bool first = true; StringBuilder builder = new StringBuilder(); foreach (MailAddress address in this) { if (!first) { builder.Append(", "); } builder.Append(address.ToString()); first = false; } return builder.ToString();; } internal string Encode(int charsConsumed) { string encodedAddresses = string.Empty; //encode each address individually (except the first), fold and separate with a comma foreach (MailAddress address in this) { if (String.IsNullOrEmpty(encodedAddresses)) { //no need to append a comma to the first one because it may be the only one. encodedAddresses = address.Encode(charsConsumed); } else { //appending another one, append a comma to separate and then fold and add the encoded address //the charsConsumed will be 1 because only the first line needs to account for the header itself for //line length; subsequent lines have a single whitespace character because they are folded here encodedAddresses += ",\r\n " + address.Encode(1); } } return encodedAddresses; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- QueryReaderSettings.cs
- StateDesignerConnector.cs
- HttpCachePolicyElement.cs
- PropertyNames.cs
- WebPartConnectionsDisconnectVerb.cs
- RouteValueDictionary.cs
- MetaType.cs
- NetCodeGroup.cs
- DataObjectAttribute.cs
- XPathSelectionIterator.cs
- TextFormatter.cs
- ContextStaticAttribute.cs
- QilXmlReader.cs
- Point3DCollection.cs
- AppliedDeviceFiltersEditor.cs
- ModelPropertyImpl.cs
- newinstructionaction.cs
- Activation.cs
- OnOperation.cs
- ByteStreamMessageEncoder.cs
- SwitchLevelAttribute.cs
- BamlResourceDeserializer.cs
- SafeHandle.cs
- StylusPointProperty.cs
- ErrorsHelper.cs
- TagMapCollection.cs
- BypassElementCollection.cs
- CompressStream.cs
- InvokeAction.cs
- BaseHashHelper.cs
- WindowsTokenRoleProvider.cs
- HttpCapabilitiesSectionHandler.cs
- KnownColorTable.cs
- SmiTypedGetterSetter.cs
- SizeChangedEventArgs.cs
- DataGridViewTextBoxEditingControl.cs
- EmptyStringExpandableObjectConverter.cs
- WebServiceHost.cs
- Package.cs
- ToolStripPanelSelectionGlyph.cs
- ProfessionalColorTable.cs
- MatrixTransform.cs
- DefaultTextStoreTextComposition.cs
- StringResourceManager.cs
- BooleanFunctions.cs
- streamingZipPartStream.cs
- Main.cs
- CompiledIdentityConstraint.cs
- ConfigsHelper.cs
- HealthMonitoringSectionHelper.cs
- DrawingVisualDrawingContext.cs
- LinkedResource.cs
- SqlGatherProducedAliases.cs
- SoapAttributes.cs
- Token.cs
- SamlAuthenticationClaimResource.cs
- InputProcessorProfiles.cs
- GridViewDeleteEventArgs.cs
- NamedServiceModelExtensionCollectionElement.cs
- ClientUtils.cs
- CollectionBuilder.cs
- IpcServerChannel.cs
- followingsibling.cs
- NamespaceQuery.cs
- ElementProxy.cs
- PrintPreviewDialog.cs
- WebContext.cs
- SecurityNegotiationException.cs
- Authorization.cs
- XslAst.cs
- ErasingStroke.cs
- SQLGuidStorage.cs
- Panel.cs
- DataGridViewCellLinkedList.cs
- ProfileSettings.cs
- HttpListenerPrefixCollection.cs
- OrderedDictionary.cs
- AsyncOperation.cs
- OutputCacheSection.cs
- ArrayList.cs
- MasterPageCodeDomTreeGenerator.cs
- Root.cs
- InteropBitmapSource.cs
- SecurityHelper.cs
- Renderer.cs
- MetabaseSettingsIis7.cs
- CodeGenerator.cs
- ProxyHelper.cs
- PropertyChangingEventArgs.cs
- HierarchicalDataSourceControl.cs
- Quad.cs
- ManifestResourceInfo.cs
- FloaterParagraph.cs
- HtmlInputCheckBox.cs
- PrefixHandle.cs
- BitmapEffectDrawingContextState.cs
- SafeNativeMethodsCLR.cs
- EventData.cs
- IndicFontClient.cs
- DateTimeParse.cs