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
- Boolean.cs
- DesignerPerfEventProvider.cs
- SmiMetaData.cs
- ProtectedConfigurationSection.cs
- EncoderParameter.cs
- UIElementIsland.cs
- UseAttributeSetsAction.cs
- DetailsViewUpdateEventArgs.cs
- DescendantQuery.cs
- BrowserDefinitionCollection.cs
- XPathException.cs
- ProjectedSlot.cs
- FileSystemEventArgs.cs
- PropertyBuilder.cs
- LinearKeyFrames.cs
- MonthCalendarDesigner.cs
- MatrixTransform.cs
- QueryOutputWriter.cs
- PersistChildrenAttribute.cs
- IItemContainerGenerator.cs
- EnumerableCollectionView.cs
- ColorAnimation.cs
- TreeChangeInfo.cs
- ReceiveDesigner.xaml.cs
- BoundField.cs
- TypeExtensionConverter.cs
- StylusPoint.cs
- ToolStripItemRenderEventArgs.cs
- IntSumAggregationOperator.cs
- TimelineClockCollection.cs
- DiagnosticsConfigurationHandler.cs
- IdentitySection.cs
- ConfigUtil.cs
- SHA256Cng.cs
- MethodCallTranslator.cs
- EllipseGeometry.cs
- SHA256CryptoServiceProvider.cs
- WebServiceErrorEvent.cs
- HttpResponseBase.cs
- ReliableInputConnection.cs
- ObjectHandle.cs
- AttributeCollection.cs
- WindowInteropHelper.cs
- GPStream.cs
- StringToken.cs
- WebPartCatalogAddVerb.cs
- Int64KeyFrameCollection.cs
- UiaCoreApi.cs
- EastAsianLunisolarCalendar.cs
- ToolBarButtonClickEvent.cs
- ThrowHelper.cs
- WindowsFormsSectionHandler.cs
- XPathNode.cs
- TextFormatterImp.cs
- SmiEventSink_DeferedProcessing.cs
- CodeValidator.cs
- Rotation3D.cs
- Menu.cs
- OciHandle.cs
- MexNamedPipeBindingElement.cs
- XmlNodeReader.cs
- ValueUnavailableException.cs
- LicenseProviderAttribute.cs
- CollectionConverter.cs
- OdbcConnectionString.cs
- SubordinateTransaction.cs
- StringSorter.cs
- URLMembershipCondition.cs
- ObservableDictionary.cs
- SendingRequestEventArgs.cs
- Classification.cs
- DrawingGroup.cs
- RenderTargetBitmap.cs
- SchemaCollectionCompiler.cs
- CorrelationTokenTypeConvertor.cs
- DataSourceXmlAttributeAttribute.cs
- ConfigXmlSignificantWhitespace.cs
- DataGridViewRowCollection.cs
- ErrorWebPart.cs
- CodeAccessSecurityEngine.cs
- CustomCredentialPolicy.cs
- ControlBuilderAttribute.cs
- MemberRelationshipService.cs
- PropertyKey.cs
- ClearCollection.cs
- BoundPropertyEntry.cs
- WebBrowserNavigatingEventHandler.cs
- XmlEventCache.cs
- InvokePattern.cs
- ExpandableObjectConverter.cs
- Activator.cs
- SeverityFilter.cs
- AutomationEventArgs.cs
- GridItemCollection.cs
- SqlBuilder.cs
- Rule.cs
- ProcessProtocolHandler.cs
- LogRestartAreaEnumerator.cs
- XPathCompileException.cs
- MdImport.cs