Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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
- PropertyInformationCollection.cs
- SaveFileDialogDesigner.cs
- __ConsoleStream.cs
- ParamArrayAttribute.cs
- PeerIPHelper.cs
- CryptoStream.cs
- TrackingMemoryStream.cs
- COM2TypeInfoProcessor.cs
- ValueHandle.cs
- CommandHelper.cs
- XamlPathDataSerializer.cs
- TemplateContainer.cs
- FormatControl.cs
- ControlsConfig.cs
- SchemaImporterExtensionElement.cs
- DataProviderNameConverter.cs
- RenderDataDrawingContext.cs
- GregorianCalendar.cs
- SequentialOutput.cs
- WsdlBuildProvider.cs
- ImageCreator.cs
- InputEventArgs.cs
- StringToken.cs
- ThemeDirectoryCompiler.cs
- FlowDocumentFormatter.cs
- LicFileLicenseProvider.cs
- HtmlWindowCollection.cs
- SelectionHighlightInfo.cs
- EpmAttributeNameBuilder.cs
- XmlnsDefinitionAttribute.cs
- FontUnitConverter.cs
- WsatProxy.cs
- EventBuilder.cs
- MeshGeometry3D.cs
- UIElementPropertyUndoUnit.cs
- CodePageUtils.cs
- LinearGradientBrush.cs
- PermissionAttributes.cs
- SchemaMerger.cs
- HttpDebugHandler.cs
- querybuilder.cs
- DropDownList.cs
- StylusEditingBehavior.cs
- XmlAutoDetectWriter.cs
- SystemInformation.cs
- StringUtil.cs
- CaseExpr.cs
- ManualResetEvent.cs
- InstanceBehavior.cs
- FontCacheUtil.cs
- WpfWebRequestHelper.cs
- TextDecoration.cs
- GridLengthConverter.cs
- WindowsTokenRoleProvider.cs
- UIElement3D.cs
- XamlInterfaces.cs
- PathNode.cs
- CodeValidator.cs
- ObjectStorage.cs
- RijndaelManaged.cs
- SqlClientWrapperSmiStreamChars.cs
- DialogWindow.cs
- PagesSection.cs
- FrameSecurityDescriptor.cs
- SamlAudienceRestrictionCondition.cs
- XmlnsDefinitionAttribute.cs
- Process.cs
- DataGridViewBand.cs
- ControlEvent.cs
- SHA512Cng.cs
- XmlDataSource.cs
- ToolboxSnapDragDropEventArgs.cs
- StringResourceManager.cs
- LayoutTableCell.cs
- SelectionHighlightInfo.cs
- XhtmlBasicLabelAdapter.cs
- Int32RectConverter.cs
- SelectManyQueryOperator.cs
- RtfFormatStack.cs
- ValidatingPropertiesEventArgs.cs
- XsltCompileContext.cs
- TextAction.cs
- DurationConverter.cs
- ListItemViewAttribute.cs
- TextSelectionHelper.cs
- AssemblyUtil.cs
- TextEndOfLine.cs
- ObjectStorage.cs
- XamlReader.cs
- RuleRefElement.cs
- XmlSchemaExternal.cs
- UrlMappingsModule.cs
- InputScope.cs
- AutomationPropertyInfo.cs
- MouseDevice.cs
- Condition.cs
- XamlToRtfParser.cs
- DataGridViewRowHeaderCell.cs
- VoiceInfo.cs
- PathSegmentCollection.cs