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
- TimeEnumHelper.cs
- StateDesigner.LayoutSelectionGlyph.cs
- EndpointDispatcherTable.cs
- StructuredType.cs
- DateTimeEditor.cs
- ConnectionConsumerAttribute.cs
- StylusDownEventArgs.cs
- CommonDialog.cs
- Content.cs
- OrderByQueryOptionExpression.cs
- XmlArrayItemAttributes.cs
- ApplicationTrust.cs
- Matrix3DValueSerializer.cs
- NopReturnReader.cs
- Filter.cs
- TypeContext.cs
- SubMenuStyle.cs
- AbsoluteQuery.cs
- RequestCacheEntry.cs
- SafePointer.cs
- HandlerFactoryWrapper.cs
- PropertyDescriptorGridEntry.cs
- EntityKeyElement.cs
- Ray3DHitTestResult.cs
- SignedXml.cs
- MessageContractMemberAttribute.cs
- NotifyIcon.cs
- TableCellCollection.cs
- WebBrowserEvent.cs
- PresentationSource.cs
- MarshalByRefObject.cs
- GetWinFXPath.cs
- CodeTypeParameter.cs
- RuleSetBrowserDialog.cs
- CurrentChangingEventManager.cs
- GridViewSortEventArgs.cs
- CodeCommentStatement.cs
- DiagnosticsConfiguration.cs
- EntityTypeEmitter.cs
- DataGridViewColumnCollection.cs
- TextBox.cs
- CFGGrammar.cs
- QueryResultOp.cs
- EntityContainer.cs
- XmlDigitalSignatureProcessor.cs
- RootBrowserWindowAutomationPeer.cs
- X509KeyIdentifierClauseType.cs
- UInt32.cs
- BitmapMetadataEnumerator.cs
- ReadOnlyCollection.cs
- PartialTrustVisibleAssembly.cs
- SByte.cs
- ValueSerializer.cs
- ImageMapEventArgs.cs
- UIHelper.cs
- EditingMode.cs
- RawStylusInputCustomDataList.cs
- BitConverter.cs
- Double.cs
- ListViewPagedDataSource.cs
- ReferentialConstraint.cs
- BitSet.cs
- InstanceData.cs
- GroupJoinQueryOperator.cs
- ExtensionDataReader.cs
- TemplateManager.cs
- ErrorTableItemStyle.cs
- XmlDocument.cs
- SqlEnums.cs
- SmtpReplyReaderFactory.cs
- XmlMembersMapping.cs
- TextParagraph.cs
- XmlDocument.cs
- HtmlButton.cs
- SecurityState.cs
- ValidatedMobileControlConverter.cs
- SQLResource.cs
- XmlSchemaComplexContentExtension.cs
- PeerTransportListenAddressConverter.cs
- MetadataPropertyCollection.cs
- QueryStringParameter.cs
- D3DImage.cs
- DescendantQuery.cs
- QilInvokeLateBound.cs
- Panel.cs
- DocumentsTrace.cs
- WebMessageEncoderFactory.cs
- IntegerValidatorAttribute.cs
- DrawingVisual.cs
- DataGridViewCellPaintingEventArgs.cs
- SQLString.cs
- SqlCrossApplyToCrossJoin.cs
- DataComponentMethodGenerator.cs
- PackageDigitalSignatureManager.cs
- EnvelopedPkcs7.cs
- SafeArrayTypeMismatchException.cs
- PageBuildProvider.cs
- SynchronizationContext.cs
- ActivityExecutionContextCollection.cs
- TextTreeInsertElementUndoUnit.cs