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
- WmlObjectListAdapter.cs
- StorageInfo.cs
- WebBrowserContainer.cs
- CodeObjectCreateExpression.cs
- ComplusTypeValidator.cs
- ValueUtilsSmi.cs
- CapabilitiesAssignment.cs
- ProxyWebPartConnectionCollection.cs
- ConfigurationSectionGroupCollection.cs
- XslTransform.cs
- SelectionProcessor.cs
- InputScopeAttribute.cs
- XmlSchemaDatatype.cs
- StrictAndMessageFilter.cs
- RowCache.cs
- StaticExtension.cs
- TreeNodeMouseHoverEvent.cs
- FormattedTextSymbols.cs
- RSAOAEPKeyExchangeDeformatter.cs
- MouseActionValueSerializer.cs
- NetMsmqSecurityMode.cs
- SpellerStatusTable.cs
- ScriptingProfileServiceSection.cs
- HtmlInputRadioButton.cs
- ConnectionInterfaceCollection.cs
- ScrollPattern.cs
- DrawingBrush.cs
- ByteStreamMessageEncoder.cs
- ExcCanonicalXml.cs
- XmlSchemaType.cs
- DataView.cs
- StringInfo.cs
- UInt64Converter.cs
- DashStyles.cs
- RoutedPropertyChangedEventArgs.cs
- DynamicPhysicalDiscoSearcher.cs
- BuildManagerHost.cs
- MethodToken.cs
- SqlStream.cs
- Semaphore.cs
- OutputBuffer.cs
- TextFormatterImp.cs
- TemplateBindingExtensionConverter.cs
- DesignerDataView.cs
- WpfWebRequestHelper.cs
- StylusEditingBehavior.cs
- ContextActivityUtils.cs
- GlobalProxySelection.cs
- FilterEventArgs.cs
- MetadataCacheItem.cs
- SmtpReplyReaderFactory.cs
- ProcessManager.cs
- PrintPreviewDialog.cs
- ParseHttpDate.cs
- SharedConnectionInfo.cs
- FlowDocumentPaginator.cs
- OneOfTypeConst.cs
- WebPartEditorCancelVerb.cs
- FileAuthorizationModule.cs
- X509Certificate2Collection.cs
- SupportsEventValidationAttribute.cs
- M3DUtil.cs
- ResolveCriteriaApril2005.cs
- HtmlControl.cs
- SqlConnectionPoolProviderInfo.cs
- ValueOfAction.cs
- TextDecorationCollectionConverter.cs
- counter.cs
- SharedPerformanceCounter.cs
- FormsAuthentication.cs
- MappingModelBuildProvider.cs
- SqlCaseSimplifier.cs
- CollectionExtensions.cs
- ObjectStorage.cs
- AdRotator.cs
- MenuItem.cs
- DictionarySectionHandler.cs
- ActivityTypeCodeDomSerializer.cs
- TextBox.cs
- BinaryQueryOperator.cs
- SoapCommonClasses.cs
- MessageFormatterConverter.cs
- ProviderConnectionPointCollection.cs
- ScopelessEnumAttribute.cs
- InvalidCommandTreeException.cs
- RenderDataDrawingContext.cs
- ComplexBindingPropertiesAttribute.cs
- cookiecontainer.cs
- CleanUpVirtualizedItemEventArgs.cs
- ReadOnlyTernaryTree.cs
- PropertyGridDesigner.cs
- CreateUserWizardStep.cs
- BinaryObjectInfo.cs
- PrintControllerWithStatusDialog.cs
- MenuTracker.cs
- DataTableReader.cs
- WinEventTracker.cs
- ListenDesigner.cs
- FormViewDeletedEventArgs.cs
- CompilationSection.cs