Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Net / System / Net / Mail / AttachmentCollection.cs / 1305376 / 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
- LinkLabel.cs
- PropertyInfoSet.cs
- CallbackValidatorAttribute.cs
- ScriptControl.cs
- SignatureHelper.cs
- DataGridCaption.cs
- AncillaryOps.cs
- SerializationBinder.cs
- StringAttributeCollection.cs
- Relationship.cs
- LineProperties.cs
- NavigationPropertyEmitter.cs
- BamlLocalizer.cs
- DataServiceKeyAttribute.cs
- TraceListener.cs
- HttpResponse.cs
- Geometry.cs
- ToolStripContainerActionList.cs
- SQLGuidStorage.cs
- ThemeDirectoryCompiler.cs
- SendMessageContent.cs
- RemoteHelper.cs
- StylusPointPropertyId.cs
- SimpleModelProvider.cs
- SystemResources.cs
- ACL.cs
- RecognizedPhrase.cs
- XmlSigningNodeWriter.cs
- HeaderUtility.cs
- ConsumerConnectionPoint.cs
- OperationDescriptionCollection.cs
- GCHandleCookieTable.cs
- SettingsAttributes.cs
- ListContractAdapter.cs
- XmlILIndex.cs
- OleDbMetaDataFactory.cs
- ApplicationServicesHostFactory.cs
- AddInSegmentDirectoryNotFoundException.cs
- BindingSource.cs
- CodeTryCatchFinallyStatement.cs
- TextBoxAutoCompleteSourceConverter.cs
- Point3DCollectionConverter.cs
- MonthCalendar.cs
- AppModelKnownContentFactory.cs
- SelectionHighlightInfo.cs
- GroupBoxAutomationPeer.cs
- MethodAccessException.cs
- CodeDomSerializerBase.cs
- CustomAssemblyResolver.cs
- VideoDrawing.cs
- MenuAdapter.cs
- CapabilitiesState.cs
- Rotation3DAnimationBase.cs
- TypeListConverter.cs
- StreamGeometry.cs
- LexicalChunk.cs
- CellParagraph.cs
- ConfigsHelper.cs
- ImmutableDispatchRuntime.cs
- XmlDataSource.cs
- XsdDataContractImporter.cs
- SafeLibraryHandle.cs
- CheckBoxAutomationPeer.cs
- PagerSettings.cs
- PackageFilter.cs
- _IPv6Address.cs
- RowSpanVector.cs
- ColumnHeaderConverter.cs
- SchemaReference.cs
- EditBehavior.cs
- TemplateXamlParser.cs
- DesignerAdapterAttribute.cs
- PageStatePersister.cs
- MetadataUtil.cs
- Utility.cs
- XmlTypeAttribute.cs
- DocumentApplicationJournalEntryEventArgs.cs
- ResXFileRef.cs
- MLangCodePageEncoding.cs
- WebPartDisplayModeCollection.cs
- AsyncCompletedEventArgs.cs
- ToolStripGripRenderEventArgs.cs
- AsnEncodedData.cs
- Model3DGroup.cs
- FilteredDataSetHelper.cs
- ModelChangedEventArgsImpl.cs
- ButtonBaseDesigner.cs
- Math.cs
- DependencyObjectPropertyDescriptor.cs
- DateTimeStorage.cs
- UnsignedPublishLicense.cs
- StoreItemCollection.cs
- XmlUTF8TextWriter.cs
- DrawListViewSubItemEventArgs.cs
- SecureConversationVersion.cs
- TabItem.cs
- StringInfo.cs
- ResourceDescriptionAttribute.cs
- InstalledFontCollection.cs
- SectionInput.cs