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
- _NetworkingPerfCounters.cs
- UpWmlPageAdapter.cs
- ScriptComponentDescriptor.cs
- TypeSchema.cs
- AuthorizationSection.cs
- XPathDocumentNavigator.cs
- LogSwitch.cs
- _NetRes.cs
- BitmapScalingModeValidation.cs
- Keywords.cs
- ClientFormsAuthenticationCredentials.cs
- _TimerThread.cs
- NameSpaceEvent.cs
- CapabilitiesPattern.cs
- ContentTextAutomationPeer.cs
- BuildProvider.cs
- PropertyPath.cs
- ModuleConfigurationInfo.cs
- UnsafeNativeMethods.cs
- ListViewSortEventArgs.cs
- SoapConverter.cs
- EmptyStringExpandableObjectConverter.cs
- _NetworkingPerfCounters.cs
- ThreadNeutralSemaphore.cs
- WebPartTransformerCollection.cs
- DelegateOutArgument.cs
- SoapTypeAttribute.cs
- DoubleStorage.cs
- NameValuePermission.cs
- TypeDependencyAttribute.cs
- SqlTypesSchemaImporter.cs
- SelectionWordBreaker.cs
- MarkupCompilePass1.cs
- HtmlGenericControl.cs
- SQLRoleProvider.cs
- StringKeyFrameCollection.cs
- MsmqInputChannel.cs
- PageBuildProvider.cs
- TemplateManager.cs
- ValidationSummary.cs
- Int16Converter.cs
- ObjectDataSourceChooseTypePanel.cs
- SqlEnums.cs
- HijriCalendar.cs
- MsmqTransportReceiveParameters.cs
- SqlExpander.cs
- SessionIDManager.cs
- SponsorHelper.cs
- ImageSourceConverter.cs
- LayoutTable.cs
- TypographyProperties.cs
- WindowsContainer.cs
- Speller.cs
- GenericTextProperties.cs
- NativeMethods.cs
- StorageMappingItemCollection.cs
- ThreadStartException.cs
- Block.cs
- WebReferencesBuildProvider.cs
- InsufficientExecutionStackException.cs
- SystemInfo.cs
- InputMethod.cs
- StringUtil.cs
- EnumMember.cs
- PerCallInstanceContextProvider.cs
- ColorMatrix.cs
- ParseElementCollection.cs
- EntityException.cs
- ping.cs
- ProfilePropertySettingsCollection.cs
- DataGridTablesFactory.cs
- BatchParser.cs
- Select.cs
- LinkArea.cs
- String.cs
- counter.cs
- Array.cs
- SqlDataSourceCache.cs
- AndAlso.cs
- PermissionAttributes.cs
- GlobalizationAssembly.cs
- StringSorter.cs
- XpsFontSerializationService.cs
- SynchronizingStream.cs
- ThemeInfoAttribute.cs
- ProcessInputEventArgs.cs
- PermissionListSet.cs
- PerformanceCounterPermissionAttribute.cs
- DATA_BLOB.cs
- AttachmentCollection.cs
- OleDbCommandBuilder.cs
- SchemaElement.cs
- DesignerActionPanel.cs
- handlecollector.cs
- OperationResponse.cs
- ScrollableControl.cs
- WebPartManager.cs
- Configuration.cs
- XPathSelectionIterator.cs
- MembershipUser.cs