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
- SqlLiftIndependentRowExpressions.cs
- TraceSource.cs
- DbProviderFactoriesConfigurationHandler.cs
- HtmlElementErrorEventArgs.cs
- TextTreeText.cs
- ThreadExceptionEvent.cs
- AddingNewEventArgs.cs
- FormClosingEvent.cs
- RuleSettingsCollection.cs
- AssociationType.cs
- ExpressionPrefixAttribute.cs
- TextElement.cs
- Missing.cs
- StrokeSerializer.cs
- MessageDecoder.cs
- SwitchElementsCollection.cs
- DefinitionBase.cs
- HtmlEmptyTagControlBuilder.cs
- WebServiceHandlerFactory.cs
- ClientApiGenerator.cs
- PeerOutputChannel.cs
- RightsManagementPermission.cs
- DoubleStorage.cs
- NetTcpBindingElement.cs
- ToolStripAdornerWindowService.cs
- DefaultTextStore.cs
- WaitHandle.cs
- SafeIUnknown.cs
- AttributeAction.cs
- HierarchicalDataBoundControlAdapter.cs
- sitestring.cs
- TemplatedWizardStep.cs
- BuildResultCache.cs
- SqlBulkCopyColumnMapping.cs
- LinkLabel.cs
- LogArchiveSnapshot.cs
- RefreshPropertiesAttribute.cs
- StorageMappingItemLoader.cs
- NotConverter.cs
- RegistrationServices.cs
- UnsettableComboBox.cs
- ChineseLunisolarCalendar.cs
- ThumbAutomationPeer.cs
- ProcessModuleCollection.cs
- RegexTree.cs
- GetRecipientRequest.cs
- MatchAllMessageFilter.cs
- HashHelper.cs
- CorePropertiesFilter.cs
- UnhandledExceptionEventArgs.cs
- PortCache.cs
- AuthenticationConfig.cs
- BulletChrome.cs
- ExpressionDumper.cs
- SystemColorTracker.cs
- ISO2022Encoding.cs
- Rotation3DAnimationUsingKeyFrames.cs
- ArrayTypeMismatchException.cs
- VSWCFServiceContractGenerator.cs
- Drawing.cs
- EmptyEnumerator.cs
- BooleanKeyFrameCollection.cs
- WebConfigurationFileMap.cs
- MessagePartSpecification.cs
- BackStopAuthenticationModule.cs
- AssemblyResourceLoader.cs
- DependencyProperty.cs
- CodeIdentifier.cs
- WebPartEditorOkVerb.cs
- SocketInformation.cs
- DataTransferEventArgs.cs
- QilLoop.cs
- MessageQueuePermissionEntryCollection.cs
- BitmapFrameDecode.cs
- Util.cs
- TdsParameterSetter.cs
- RSAPKCS1SignatureFormatter.cs
- CodeIdentifiers.cs
- Vector3DAnimation.cs
- BaseDataListActionList.cs
- UpdateExpressionVisitor.cs
- FileDialog_Vista.cs
- BasicExpressionVisitor.cs
- OutputScopeManager.cs
- CodeCommentStatementCollection.cs
- FontInfo.cs
- RemotingHelper.cs
- ObservableCollection.cs
- diagnosticsswitches.cs
- DocumentPageTextView.cs
- DataGridItem.cs
- PackagePartCollection.cs
- ReadOnlyPropertyMetadata.cs
- FlagsAttribute.cs
- ReadOnlyDictionary.cs
- OrderByQueryOptionExpression.cs
- PipelineDeploymentState.cs
- LinqToSqlWrapper.cs
- WindowsAuthenticationModule.cs
- EntityDataSourceConfigureObjectContext.cs