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
- ResourceCategoryAttribute.cs
- UnsafeNativeMethods.cs
- MsmqProcessProtocolHandler.cs
- LicenseProviderAttribute.cs
- SymmetricAlgorithm.cs
- SoundPlayerAction.cs
- CompiledIdentityConstraint.cs
- ContentType.cs
- StylusPlugInCollection.cs
- ArrayHelper.cs
- DesignTimeXamlWriter.cs
- StatusBarItemAutomationPeer.cs
- CallbackValidatorAttribute.cs
- ShaderRenderModeValidation.cs
- WCFModelStrings.Designer.cs
- EasingKeyFrames.cs
- ConfigurationManagerHelperFactory.cs
- PreviewKeyDownEventArgs.cs
- ExpandCollapsePattern.cs
- TypeConverterHelper.cs
- __ConsoleStream.cs
- CharAnimationUsingKeyFrames.cs
- BinaryQueryOperator.cs
- HwndSourceParameters.cs
- ResponseBodyWriter.cs
- BitVector32.cs
- DescendantBaseQuery.cs
- ITreeGenerator.cs
- EntityDataSourceSelectedEventArgs.cs
- XDeferredAxisSource.cs
- CounterSampleCalculator.cs
- EpmSyndicationContentSerializer.cs
- ImmutableObjectAttribute.cs
- ClientProxyGenerator.cs
- HostingEnvironmentSection.cs
- PrintingPermission.cs
- PersistenceTypeAttribute.cs
- OdbcParameter.cs
- DbConnectionFactory.cs
- DnsPermission.cs
- TypeElement.cs
- URL.cs
- AssemblyResourceLoader.cs
- BuildProvidersCompiler.cs
- compensatingcollection.cs
- AccessedThroughPropertyAttribute.cs
- ApplicationBuildProvider.cs
- PackageStore.cs
- OleDbWrapper.cs
- DataGridHelper.cs
- BaseTemplateCodeDomTreeGenerator.cs
- TextBoxAutoCompleteSourceConverter.cs
- DataGridViewHeaderCell.cs
- WebCategoryAttribute.cs
- ConnectionManagementElementCollection.cs
- _HeaderInfoTable.cs
- XmlEventCache.cs
- CqlQuery.cs
- FixedBufferAttribute.cs
- XmlSerializationWriter.cs
- BinaryWriter.cs
- ToolboxComponentsCreatingEventArgs.cs
- codemethodreferenceexpression.cs
- WindowPatternIdentifiers.cs
- DetailsViewInsertedEventArgs.cs
- SymbolType.cs
- ComplexType.cs
- SynchronizedInputPattern.cs
- WpfPayload.cs
- CatalogZone.cs
- PointCollectionConverter.cs
- LogicalMethodInfo.cs
- RadioButtonList.cs
- EntityUtil.cs
- LoginName.cs
- MetadataPropertyvalue.cs
- UndoManager.cs
- StateChangeEvent.cs
- RemotingConfigParser.cs
- DocumentCollection.cs
- KeyedHashAlgorithm.cs
- PeerNameResolver.cs
- SendMailErrorEventArgs.cs
- SHA256.cs
- XPathBinder.cs
- TemplateBamlTreeBuilder.cs
- SubpageParaClient.cs
- PanelContainerDesigner.cs
- XmlByteStreamReader.cs
- filewebrequest.cs
- EntityProxyTypeInfo.cs
- Timer.cs
- TableItemStyle.cs
- FormViewPageEventArgs.cs
- BaseProcessor.cs
- ResourceAttributes.cs
- EmbeddedMailObjectsCollection.cs
- TextSimpleMarkerProperties.cs
- DecoderNLS.cs
- DES.cs