Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / Net / System / Net / Mail / AttachmentCollection.cs / 1 / AttachmentCollection.cs
using System; using System.Collections.ObjectModel; namespace System.Net.Mail { ////// Summary description for AttachmentCollection. /// public sealed class AttachmentCollection : Collection, IDisposable { bool disposed = false; internal AttachmentCollection() { } public void Dispose(){ if(disposed){ return; } foreach (Attachment attachment in this) { attachment.Dispose(); } Clear(); disposed = true; } protected override void RemoveItem(int index){ if (disposed) { throw new ObjectDisposedException(this.GetType().FullName); } base.RemoveItem(index); } protected override void ClearItems(){ if (disposed) { throw new ObjectDisposedException(this.GetType().FullName); } base.ClearItems(); } protected override void SetItem(int index, Attachment item){ if (disposed) { throw new ObjectDisposedException(this.GetType().FullName); } if(item==null) { throw new ArgumentNullException("item"); } base.SetItem(index,item); } protected override void InsertItem(int index, Attachment item){ if (disposed) { throw new ObjectDisposedException(this.GetType().FullName); } if(item==null){ throw new ArgumentNullException("item"); } base.InsertItem(index,item); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. using System; using System.Collections.ObjectModel; namespace System.Net.Mail { /// /// Summary description for AttachmentCollection. /// public sealed class AttachmentCollection : Collection, IDisposable { bool disposed = false; internal AttachmentCollection() { } public void Dispose(){ if(disposed){ return; } foreach (Attachment attachment in this) { attachment.Dispose(); } Clear(); disposed = true; } protected override void RemoveItem(int index){ if (disposed) { throw new ObjectDisposedException(this.GetType().FullName); } base.RemoveItem(index); } protected override void ClearItems(){ if (disposed) { throw new ObjectDisposedException(this.GetType().FullName); } base.ClearItems(); } protected override void SetItem(int index, Attachment item){ if (disposed) { throw new ObjectDisposedException(this.GetType().FullName); } if(item==null) { throw new ArgumentNullException("item"); } base.SetItem(index,item); } protected override void InsertItem(int index, Attachment item){ if (disposed) { throw new ObjectDisposedException(this.GetType().FullName); } if(item==null){ throw new ArgumentNullException("item"); } base.InsertItem(index,item); } } } // 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
- SqlDelegatedTransaction.cs
- ProcessModule.cs
- ProcessThreadCollection.cs
- HandlerBase.cs
- SystemMulticastIPAddressInformation.cs
- Quaternion.cs
- Rect3DValueSerializer.cs
- EntityCodeGenerator.cs
- HttpRequest.cs
- DbProviderManifest.cs
- MessageEncodingBindingElementImporter.cs
- DynamicEntity.cs
- Track.cs
- HtmlInputHidden.cs
- ReflectionTypeLoadException.cs
- DataGridViewUtilities.cs
- XPathSelfQuery.cs
- StickyNoteAnnotations.cs
- TextSpan.cs
- WebConfigurationHostFileChange.cs
- HtmlCommandAdapter.cs
- EdmItemCollection.OcAssemblyCache.cs
- AuthenticationModuleElementCollection.cs
- PolicyStatement.cs
- DataGridLinkButton.cs
- WpfGeneratedKnownProperties.cs
- ThemeableAttribute.cs
- LayoutTableCell.cs
- SqlReferenceCollection.cs
- LoginView.cs
- RepeatButtonAutomationPeer.cs
- WinInet.cs
- ErrorEventArgs.cs
- MetadataCache.cs
- EqualityComparer.cs
- FixedSOMSemanticBox.cs
- CapiSymmetricAlgorithm.cs
- PolyLineSegmentFigureLogic.cs
- BrushConverter.cs
- DataGridCaption.cs
- CodePropertyReferenceExpression.cs
- SafeRightsManagementHandle.cs
- SecurityState.cs
- ProviderUtil.cs
- EventDescriptor.cs
- WorkflowServiceInstance.cs
- InternalResources.cs
- StartUpEventArgs.cs
- TrustDriver.cs
- MonitoringDescriptionAttribute.cs
- CustomPopupPlacement.cs
- Parsers.cs
- MethodRental.cs
- MsmqHostedTransportManager.cs
- ProtocolViolationException.cs
- ScrollableControl.cs
- NativeActivityTransactionContext.cs
- DocumentViewerBaseAutomationPeer.cs
- TranslateTransform.cs
- Annotation.cs
- GridViewColumnCollection.cs
- PolyLineSegmentFigureLogic.cs
- FixedPosition.cs
- CheckBoxField.cs
- SiteMapProvider.cs
- NameValuePair.cs
- HeaderedContentControl.cs
- TreeIterator.cs
- VisualBasicSettingsHandler.cs
- ChannelEndpointElement.cs
- LogReserveAndAppendState.cs
- ComplexType.cs
- PerfCounterSection.cs
- SmtpTransport.cs
- SamlAuthorizationDecisionClaimResource.cs
- mactripleDES.cs
- DbDataAdapter.cs
- WebRequestModuleElement.cs
- Stackframe.cs
- Rotation3DAnimationBase.cs
- ConfigurationElement.cs
- XmlWellformedWriterHelpers.cs
- SystemMulticastIPAddressInformation.cs
- BooleanToSelectiveScrollingOrientationConverter.cs
- BrowsableAttribute.cs
- AsymmetricKeyExchangeDeformatter.cs
- TextComposition.cs
- ConfigurationSectionCollection.cs
- XPathAncestorIterator.cs
- WebPartEditVerb.cs
- TransformDescriptor.cs
- DataGridViewSelectedRowCollection.cs
- TreeNodeStyleCollection.cs
- PassportPrincipal.cs
- ViewCellRelation.cs
- SamlConditions.cs
- DataSourceHelper.cs
- ComplexBindingPropertiesAttribute.cs
- ContentElement.cs
- HwndTarget.cs