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
- ContextQuery.cs
- GridViewHeaderRowPresenter.cs
- WebMessageEncodingBindingElement.cs
- CqlBlock.cs
- TextBoxRenderer.cs
- XPathPatternBuilder.cs
- DataSysAttribute.cs
- Matrix3DConverter.cs
- XmlHierarchicalEnumerable.cs
- LOSFormatter.cs
- FormatConvertedBitmap.cs
- BitmapEncoder.cs
- EDesignUtil.cs
- CultureTableRecord.cs
- LineMetrics.cs
- PlatformCulture.cs
- SHA1.cs
- DynamicField.cs
- ExclusiveCanonicalizationTransform.cs
- TextUtf8RawTextWriter.cs
- EncoderNLS.cs
- ToolStripButton.cs
- SerializationUtility.cs
- ExpressionPrinter.cs
- CodeTypeDelegate.cs
- DefaultTraceListener.cs
- DesignSurface.cs
- IHttpResponseInternal.cs
- PrintPreviewControl.cs
- StrongNameMembershipCondition.cs
- ImageFormatConverter.cs
- ProfileBuildProvider.cs
- Span.cs
- DataGridViewControlCollection.cs
- ZipIOLocalFileDataDescriptor.cs
- counter.cs
- SymmetricAlgorithm.cs
- MimeMapping.cs
- ConstrainedDataObject.cs
- SystemDiagnosticsSection.cs
- SQLBoolean.cs
- StatusBarDesigner.cs
- XhtmlStyleClass.cs
- BaseTypeViewSchema.cs
- Html32TextWriter.cs
- ConnectionOrientedTransportManager.cs
- References.cs
- DictionaryKeyPropertyAttribute.cs
- Parallel.cs
- LassoHelper.cs
- RegexWorker.cs
- ObjectConverter.cs
- Cloud.cs
- PtsHelper.cs
- PolicyValidator.cs
- EnumerableRowCollectionExtensions.cs
- InternalConfigRoot.cs
- WebPermission.cs
- TemplateBindingExpressionConverter.cs
- ToggleButton.cs
- MatrixTransform.cs
- RepeaterCommandEventArgs.cs
- VariantWrapper.cs
- FontClient.cs
- XsltSettings.cs
- SiteMapProvider.cs
- MSAANativeProvider.cs
- FigureParaClient.cs
- ClusterRegistryConfigurationProvider.cs
- BrowserCapabilitiesCompiler.cs
- DetailsViewDeleteEventArgs.cs
- CharStorage.cs
- ScrollProperties.cs
- AutoSizeComboBox.cs
- BasicCellRelation.cs
- IApplicationTrustManager.cs
- UnitySerializationHolder.cs
- DropTarget.cs
- DivideByZeroException.cs
- TypeForwardedFromAttribute.cs
- KeyNameIdentifierClause.cs
- PermissionListSet.cs
- TabletCollection.cs
- ModuleBuilderData.cs
- MimeWriter.cs
- ComplexType.cs
- DomNameTable.cs
- QueryContinueDragEventArgs.cs
- ping.cs
- CustomCredentialPolicy.cs
- RectangleHotSpot.cs
- DelegatingTypeDescriptionProvider.cs
- WithParamAction.cs
- DataGridViewEditingControlShowingEventArgs.cs
- FontWeightConverter.cs
- UnsafeNetInfoNativeMethods.cs
- BitFlagsGenerator.cs
- DoWhile.cs
- Translator.cs
- WebBrowserEvent.cs