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
- InfoCardTrace.cs
- SqlStream.cs
- JournalEntryStack.cs
- WaitForChangedResult.cs
- ToolboxItemFilterAttribute.cs
- VBIdentifierName.cs
- OleDbSchemaGuid.cs
- DataSpaceManager.cs
- Constraint.cs
- Number.cs
- Deflater.cs
- CookieParameter.cs
- PathGradientBrush.cs
- DataGridViewElement.cs
- TraceUtils.cs
- EnterpriseServicesHelper.cs
- CapabilitiesSection.cs
- DoubleConverter.cs
- ModelTypeConverter.cs
- SemanticTag.cs
- ServiceDiscoveryBehavior.cs
- FileVersionInfo.cs
- StrokeNode.cs
- InvalidOperationException.cs
- DataGridViewDataConnection.cs
- GenericUriParser.cs
- SelectionRangeConverter.cs
- SqlExpressionNullability.cs
- SiteMapPath.cs
- HttpListenerRequest.cs
- Cursor.cs
- EventData.cs
- ExpressionReplacer.cs
- DecodeHelper.cs
- ListViewContainer.cs
- CssClassPropertyAttribute.cs
- XmlDownloadManager.cs
- PersonalizationProvider.cs
- InstalledFontCollection.cs
- UnmanagedMarshal.cs
- DependencyObject.cs
- DataGridViewImageCell.cs
- TextPointer.cs
- Button.cs
- ThemeDirectoryCompiler.cs
- RegexCompiler.cs
- ArgumentException.cs
- _SslStream.cs
- LeftCellWrapper.cs
- URLString.cs
- DbBuffer.cs
- OdbcRowUpdatingEvent.cs
- PersonalizationProvider.cs
- SafeFileHandle.cs
- StateItem.cs
- AppLevelCompilationSectionCache.cs
- ReadOnlyMetadataCollection.cs
- TableLayoutCellPaintEventArgs.cs
- CodeMethodReturnStatement.cs
- SQLMembershipProvider.cs
- UpDownEvent.cs
- FrameworkRichTextComposition.cs
- WebPartConnection.cs
- ListItemsCollectionEditor.cs
- DesignerCapabilities.cs
- UnwrappedTypesXmlSerializerManager.cs
- StringDictionary.cs
- OptimizedTemplateContent.cs
- Set.cs
- ExpressionVisitor.cs
- EnumValAlphaComparer.cs
- XmlDeclaration.cs
- TextTreeText.cs
- Point3DKeyFrameCollection.cs
- DesignerResources.cs
- SupportsPreviewControlAttribute.cs
- ExtendedPropertyCollection.cs
- WriteableBitmap.cs
- HttpCapabilitiesSectionHandler.cs
- CommandHelpers.cs
- PathSegmentCollection.cs
- PeerNameResolver.cs
- Addressing.cs
- HostedNamedPipeTransportManager.cs
- SqlServer2KCompatibilityCheck.cs
- RtType.cs
- DataGridCell.cs
- HtmlInputPassword.cs
- IgnorePropertiesAttribute.cs
- SyndicationElementExtensionCollection.cs
- ApplicationSecurityManager.cs
- ModuleElement.cs
- ExpandSegmentCollection.cs
- SQLCharsStorage.cs
- HybridDictionary.cs
- ConsoleEntryPoint.cs
- _TransmitFileOverlappedAsyncResult.cs
- SqlClientFactory.cs
- DropSource.cs
- OutputCache.cs