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
- FtpWebResponse.cs
- ExpressionVisitorHelpers.cs
- BrowsableAttribute.cs
- FixedSOMFixedBlock.cs
- DocumentPageView.cs
- EventLogPermissionEntry.cs
- SqlFactory.cs
- rsa.cs
- OleStrCAMarshaler.cs
- HtmlWindow.cs
- DateTimeParse.cs
- MergablePropertyAttribute.cs
- TableLayoutCellPaintEventArgs.cs
- BaseValidator.cs
- InnerItemCollectionView.cs
- ListBox.cs
- StateDesignerConnector.cs
- UpdateProgress.cs
- VisualTreeHelper.cs
- BrowserInteropHelper.cs
- SystemThemeKey.cs
- ArraySegment.cs
- Bits.cs
- TextDpi.cs
- IconHelper.cs
- RegexWriter.cs
- Comparer.cs
- TableRow.cs
- IdleTimeoutMonitor.cs
- InteropBitmapSource.cs
- XPathDocumentIterator.cs
- DigitShape.cs
- TrackingAnnotationCollection.cs
- TextSelectionHelper.cs
- WebDisplayNameAttribute.cs
- ChannelServices.cs
- TypeElementCollection.cs
- Selection.cs
- ListViewItemEventArgs.cs
- WebPartConnection.cs
- DrawingBrush.cs
- ColumnResizeUndoUnit.cs
- AsymmetricSignatureDeformatter.cs
- DrawingBrush.cs
- Accessible.cs
- DataGridTextBox.cs
- ISFTagAndGuidCache.cs
- XamlTypeMapper.cs
- DBCommand.cs
- RangeValidator.cs
- SmtpReplyReaderFactory.cs
- CodeAttachEventStatement.cs
- ThicknessAnimationUsingKeyFrames.cs
- RightsManagementSuppressedStream.cs
- LicenseException.cs
- RetriableClipboard.cs
- TypedTableHandler.cs
- SqlConnectionManager.cs
- PrivilegeNotHeldException.cs
- PagesSection.cs
- DbDataSourceEnumerator.cs
- GlobalDataBindingHandler.cs
- PenLineCapValidation.cs
- LinkClickEvent.cs
- GridViewDeletedEventArgs.cs
- SubstitutionList.cs
- DemultiplexingClientMessageFormatter.cs
- PrintPreviewDialog.cs
- sqlstateclientmanager.cs
- LinkTarget.cs
- ParameterCollection.cs
- ZipIOZip64EndOfCentralDirectoryBlock.cs
- Debug.cs
- Rotation3DKeyFrameCollection.cs
- NavigationWindow.cs
- FilteredDataSetHelper.cs
- TripleDES.cs
- KeyFrames.cs
- DbXmlEnabledProviderManifest.cs
- QilReplaceVisitor.cs
- CodeNamespace.cs
- Request.cs
- DesignBindingEditor.cs
- storepermission.cs
- GatewayIPAddressInformationCollection.cs
- HighContrastHelper.cs
- ApplicationHost.cs
- RtfToken.cs
- X509Certificate2.cs
- ToolStripProfessionalLowResolutionRenderer.cs
- SafeNativeMethodsMilCoreApi.cs
- NameValuePair.cs
- SubMenuStyle.cs
- XmlSchemaObjectCollection.cs
- CompensationHandlingFilter.cs
- SignatureDescription.cs
- _ListenerResponseStream.cs
- LambdaCompiler.Binary.cs
- Rect3DValueSerializer.cs
- CustomAttributeBuilder.cs