Code:
/ 4.0 / 4.0 / 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. //------------------------------------------------------------------------------ // // 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
- ListViewDeletedEventArgs.cs
- HostedHttpRequestAsyncResult.cs
- LinqExpressionNormalizer.cs
- DataGridViewCellStateChangedEventArgs.cs
- RetrieveVirtualItemEventArgs.cs
- NameValueCollection.cs
- BasePattern.cs
- ApplicationContext.cs
- SetIterators.cs
- AspNetPartialTrustHelpers.cs
- StrongNamePublicKeyBlob.cs
- MatrixIndependentAnimationStorage.cs
- DockPanel.cs
- PersistencePipeline.cs
- IsolatedStoragePermission.cs
- XmlIgnoreAttribute.cs
- MappingSource.cs
- Evidence.cs
- EmbeddedMailObject.cs
- ReadOnlyTernaryTree.cs
- AnonymousIdentificationSection.cs
- NamespaceInfo.cs
- updatecommandorderer.cs
- BinaryQueryOperator.cs
- TypeListConverter.cs
- Stack.cs
- RadialGradientBrush.cs
- GroupJoinQueryOperator.cs
- IntMinMaxAggregationOperator.cs
- PeerApplicationLaunchInfo.cs
- XmlQueryContext.cs
- SqlNodeAnnotations.cs
- IFlowDocumentViewer.cs
- GenericRootAutomationPeer.cs
- PagesSection.cs
- SafeProcessHandle.cs
- ResourceManagerWrapper.cs
- AccessDataSource.cs
- QilNode.cs
- GreenMethods.cs
- ColorPalette.cs
- NullRuntimeConfig.cs
- CSharpCodeProvider.cs
- ViewStateModeByIdAttribute.cs
- SelectionRange.cs
- BidOverLoads.cs
- QueryAccessibilityHelpEvent.cs
- EntitySqlException.cs
- ModuleBuilderData.cs
- CardSpacePolicyElement.cs
- XmlText.cs
- AsyncOperation.cs
- TemplateInstanceAttribute.cs
- MetadataFile.cs
- ListBindingConverter.cs
- SmiMetaData.cs
- Transform3DCollection.cs
- RadioButtonBaseAdapter.cs
- Exceptions.cs
- TrackBarRenderer.cs
- OutputCacheSettingsSection.cs
- ThicknessAnimation.cs
- SecurityKeyIdentifierClause.cs
- X509Utils.cs
- HtmlInputHidden.cs
- FactoryMaker.cs
- shaperfactoryquerycachekey.cs
- Calendar.cs
- MediaTimeline.cs
- XmlDesignerDataSourceView.cs
- VisualProxy.cs
- TypeDescriptionProviderAttribute.cs
- RegionIterator.cs
- MethodCallTranslator.cs
- ImageAutomationPeer.cs
- SourceFileInfo.cs
- PerspectiveCamera.cs
- DelegateSerializationHolder.cs
- RepeatBehaviorConverter.cs
- BuildProviderCollection.cs
- TableCellCollection.cs
- IntPtr.cs
- EndpointAddressMessageFilter.cs
- PropertySourceInfo.cs
- BackgroundWorker.cs
- SafeNativeMethods.cs
- TextElementEnumerator.cs
- DynamicDocumentPaginator.cs
- CssStyleCollection.cs
- TdsParserStaticMethods.cs
- InkPresenter.cs
- DefaultTextStore.cs
- InternalMappingException.cs
- WaitHandle.cs
- WorkflowShape.cs
- Exception.cs
- HtmlLinkAdapter.cs
- WindowsSecurityTokenAuthenticator.cs
- WindowsListViewItemCheckBox.cs
- EncryptedKey.cs