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
- MouseButtonEventArgs.cs
- MetadataLocation.cs
- SqlNodeTypeOperators.cs
- ContentTextAutomationPeer.cs
- LocalBuilder.cs
- XmlUtf8RawTextWriter.cs
- BitConverter.cs
- FilteredXmlReader.cs
- WindowsSolidBrush.cs
- RegistryKey.cs
- DelegateSerializationHolder.cs
- StylusPointProperty.cs
- SQLGuidStorage.cs
- FileChangesMonitor.cs
- WebPartCloseVerb.cs
- HttpApplicationStateWrapper.cs
- PropertyStore.cs
- ExpressionBinding.cs
- ElementAction.cs
- RectangleGeometry.cs
- FieldMetadata.cs
- TreeViewHitTestInfo.cs
- HwndMouseInputProvider.cs
- SelectionItemPatternIdentifiers.cs
- FixedTextView.cs
- TemplateControlBuildProvider.cs
- HttpChannelBindingToken.cs
- CommentAction.cs
- SmtpAuthenticationManager.cs
- Activator.cs
- NonVisualControlAttribute.cs
- NumberFunctions.cs
- BindingOperations.cs
- RelationshipDetailsRow.cs
- InstanceOwner.cs
- CombinedGeometry.cs
- Literal.cs
- TransactionFilter.cs
- PropertyPath.cs
- FamilyMapCollection.cs
- EntityDesignerDataSourceView.cs
- ContentWrapperAttribute.cs
- XmlAnyElementAttribute.cs
- DocumentPage.cs
- EventArgs.cs
- ProgressBarRenderer.cs
- Rights.cs
- BidOverLoads.cs
- PresentationAppDomainManager.cs
- ListViewCommandEventArgs.cs
- DynamicMetaObjectBinder.cs
- ConfigurationException.cs
- ConsoleTraceListener.cs
- RIPEMD160.cs
- StorageSetMapping.cs
- XPathAncestorQuery.cs
- printdlgexmarshaler.cs
- DbConnectionClosed.cs
- FormViewPagerRow.cs
- ApplicationSettingsBase.cs
- XmlILStorageConverter.cs
- LocalizableAttribute.cs
- MemberDomainMap.cs
- XmlHierarchicalDataSourceView.cs
- UserControl.cs
- ProtectedConfiguration.cs
- SoapCodeExporter.cs
- DefaultPrintController.cs
- ToolZone.cs
- Size.cs
- DocumentApplicationJournalEntry.cs
- SqlWebEventProvider.cs
- LabelDesigner.cs
- Calendar.cs
- XmlValidatingReaderImpl.cs
- MsdtcClusterUtils.cs
- TransactionException.cs
- ToolStripContentPanel.cs
- TableRow.cs
- StandardCommands.cs
- PolicyChain.cs
- MemberDomainMap.cs
- XPathDocument.cs
- PathFigureCollectionConverter.cs
- Merger.cs
- ServiceConfigurationTraceRecord.cs
- RefreshPropertiesAttribute.cs
- SerialPinChanges.cs
- Delegate.cs
- DataGridViewComboBoxColumn.cs
- SchemaImporterExtensionElementCollection.cs
- DataPagerField.cs
- TreeNodeSelectionProcessor.cs
- CodeValidator.cs
- FixedSOMContainer.cs
- OutOfProcStateClientManager.cs
- ChannelTerminatedException.cs
- LongSumAggregationOperator.cs
- PathFigure.cs
- XPathEmptyIterator.cs