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
- ToolStripItemTextRenderEventArgs.cs
- Module.cs
- DocumentViewerBaseAutomationPeer.cs
- BaseParagraph.cs
- DrawingCollection.cs
- RectAnimationUsingKeyFrames.cs
- StrokeCollectionDefaultValueFactory.cs
- ContentValidator.cs
- Preprocessor.cs
- ClusterSafeNativeMethods.cs
- ByteAnimation.cs
- SpecialFolderEnumConverter.cs
- FunctionQuery.cs
- PrivateFontCollection.cs
- AnimationClockResource.cs
- ContentElementCollection.cs
- WindowShowOrOpenTracker.cs
- MetadataItemSerializer.cs
- XAMLParseException.cs
- DATA_BLOB.cs
- LinkDescriptor.cs
- DnsEndPoint.cs
- TypographyProperties.cs
- SliderAutomationPeer.cs
- HwndTarget.cs
- XmlSchemaAnyAttribute.cs
- FlowDocumentFormatter.cs
- XmlException.cs
- activationcontext.cs
- WebErrorHandler.cs
- EmptyElement.cs
- Transform.cs
- WebHostUnsafeNativeMethods.cs
- SvcMapFileSerializer.cs
- BrowserTree.cs
- TypeInfo.cs
- AnnotationResourceCollection.cs
- ConversionContext.cs
- Renderer.cs
- ResponseStream.cs
- SyndicationSerializer.cs
- xml.cs
- Interfaces.cs
- OneWayBindingElementImporter.cs
- ListParagraph.cs
- BypassElementCollection.cs
- ExpressionBuilder.cs
- SafeLibraryHandle.cs
- ValueUtilsSmi.cs
- TreeViewAutomationPeer.cs
- QuaternionRotation3D.cs
- Transform.cs
- GlobalItem.cs
- EventLogTraceListener.cs
- AccessDataSource.cs
- ToolStripButton.cs
- ActivityContext.cs
- FactoryGenerator.cs
- LocalServiceSecuritySettings.cs
- ThreadExceptionDialog.cs
- Debugger.cs
- UnmanagedMarshal.cs
- DiagnosticTraceSource.cs
- PackWebRequest.cs
- HttpCookie.cs
- CheckoutException.cs
- GuidConverter.cs
- MenuBase.cs
- BinaryNode.cs
- AccessDataSourceView.cs
- SqlProviderServices.cs
- Exceptions.cs
- ListSourceHelper.cs
- DocumentViewerBaseAutomationPeer.cs
- HebrewNumber.cs
- x509utils.cs
- Parser.cs
- DiscreteKeyFrames.cs
- ACL.cs
- WindowsIdentity.cs
- XamlReader.cs
- FunctionNode.cs
- DetailsViewPageEventArgs.cs
- DataControlExtensions.cs
- RequestCacheEntry.cs
- Rect3DValueSerializer.cs
- PrintPreviewGraphics.cs
- XsdValidatingReader.cs
- InteropAutomationProvider.cs
- _OverlappedAsyncResult.cs
- WebConfigurationManager.cs
- EmptyEnumerator.cs
- BindingRestrictions.cs
- MemberPathMap.cs
- BaseDataListDesigner.cs
- WebPartConnectionsConfigureVerb.cs
- ConnectionStringSettingsCollection.cs
- BitVector32.cs
- TextParagraphView.cs
- BitmapDecoder.cs