Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- RegularExpressionValidator.cs
- GeometryHitTestResult.cs
- ApplyTemplatesAction.cs
- LineGeometry.cs
- GridToolTip.cs
- TextFragmentEngine.cs
- IntegerFacetDescriptionElement.cs
- StretchValidation.cs
- XsltContext.cs
- ConfigurationManagerHelperFactory.cs
- ReflectionUtil.cs
- MimePart.cs
- ChannelManager.cs
- LinqDataSourceContextEventArgs.cs
- DataListCommandEventArgs.cs
- FileDialog_Vista.cs
- DBPropSet.cs
- FunctionQuery.cs
- TreeView.cs
- GiveFeedbackEvent.cs
- HasCopySemanticsAttribute.cs
- CurrentTimeZone.cs
- CaseInsensitiveHashCodeProvider.cs
- TheQuery.cs
- AndCondition.cs
- XmlSchemaSimpleContentExtension.cs
- Collection.cs
- XDeferredAxisSource.cs
- UnsafeNativeMethods.cs
- dbdatarecord.cs
- entitydatasourceentitysetnameconverter.cs
- FuncTypeConverter.cs
- HtmlTableCell.cs
- ServiceObjectContainer.cs
- DynamicEndpointElement.cs
- HttpRequestBase.cs
- ConstraintConverter.cs
- XmlComplianceUtil.cs
- FontEditor.cs
- sqlser.cs
- ThicknessConverter.cs
- ACL.cs
- DropShadowEffect.cs
- LoginCancelEventArgs.cs
- X509Certificate2Collection.cs
- WebConfigurationHost.cs
- HttpContext.cs
- codemethodreferenceexpression.cs
- ThreadAbortException.cs
- CodeValidator.cs
- Font.cs
- HighContrastHelper.cs
- HtmlLabelAdapter.cs
- MsmqTransportElement.cs
- TextTabProperties.cs
- DbMetaDataColumnNames.cs
- SoapMessage.cs
- DataGridDesigner.cs
- XmlMapping.cs
- SafeEventLogWriteHandle.cs
- PreviewPageInfo.cs
- XsdDuration.cs
- SqlSupersetValidator.cs
- WmpBitmapEncoder.cs
- _SslStream.cs
- CodeParameterDeclarationExpressionCollection.cs
- SystemIcmpV6Statistics.cs
- GridErrorDlg.cs
- PowerEase.cs
- SurrogateSelector.cs
- SamlAttribute.cs
- SurrogateChar.cs
- Blend.cs
- WeakHashtable.cs
- UnsafeNativeMethods.cs
- LassoHelper.cs
- SecurityAlgorithmSuite.cs
- ResponseStream.cs
- UnsafeNativeMethods.cs
- MenuBase.cs
- MsmqIntegrationValidationBehavior.cs
- ProfessionalColorTable.cs
- _NegotiateClient.cs
- DataFormats.cs
- PasswordDeriveBytes.cs
- MembershipPasswordException.cs
- Attributes.cs
- HttpDebugHandler.cs
- HttpModuleActionCollection.cs
- ToolStripPanelRenderEventArgs.cs
- AgileSafeNativeMemoryHandle.cs
- printdlgexmarshaler.cs
- XmlObjectSerializerReadContextComplexJson.cs
- CheckedPointers.cs
- DetailsViewUpdateEventArgs.cs
- ErrorWebPart.cs
- WindowsBrush.cs
- Brush.cs
- DataContractJsonSerializer.cs
- StorageRoot.cs