Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Net / System / Net / Mail / LinkedResourceCollection.cs / 1305376 / LinkedResourceCollection.cs
using System; using System.Collections.ObjectModel; namespace System.Net.Mail { public sealed class LinkedResourceCollection : Collection, IDisposable { bool disposed = false; internal LinkedResourceCollection() { } public void Dispose() { if(disposed){ return; } foreach (LinkedResource resource in this) { resource.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, LinkedResource 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, LinkedResource 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 { public sealed class LinkedResourceCollection : Collection , IDisposable { bool disposed = false; internal LinkedResourceCollection() { } public void Dispose() { if(disposed){ return; } foreach (LinkedResource resource in this) { resource.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, LinkedResource 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, LinkedResource 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
- MessageSmuggler.cs
- PrimitiveXmlSerializers.cs
- ToolStripItemImageRenderEventArgs.cs
- RightsManagementEncryptedStream.cs
- EventBookmark.cs
- BinaryParser.cs
- RijndaelManagedTransform.cs
- SelectionEditor.cs
- ComplexTypeEmitter.cs
- DynamicUpdateCommand.cs
- LockCookie.cs
- Translator.cs
- ConfigurationStrings.cs
- Int32AnimationUsingKeyFrames.cs
- TcpTransportSecurityElement.cs
- UnionExpr.cs
- BindingOperations.cs
- DropDownList.cs
- PageThemeCodeDomTreeGenerator.cs
- securitymgrsite.cs
- TCPClient.cs
- StateWorkerRequest.cs
- XmlSchemaExporter.cs
- PropertyFilter.cs
- EncoderParameters.cs
- JoinElimination.cs
- MergeFilterQuery.cs
- HexParser.cs
- GregorianCalendarHelper.cs
- Dictionary.cs
- TableCellCollection.cs
- DataGridViewAdvancedBorderStyle.cs
- GPPOINT.cs
- Rect3DValueSerializer.cs
- HttpCachePolicyElement.cs
- SiteMapNodeCollection.cs
- DataListItemEventArgs.cs
- TableRow.cs
- RecognizerInfo.cs
- InputReport.cs
- SmiContextFactory.cs
- XmlSchemaAppInfo.cs
- StdRegProviderWrapper.cs
- SkipStoryboardToFill.cs
- PromptStyle.cs
- TemplateBuilder.cs
- MouseEvent.cs
- FileClassifier.cs
- ObjectItemConventionAssemblyLoader.cs
- JsonReaderWriterFactory.cs
- ExceptionRoutedEventArgs.cs
- SpoolingTask.cs
- FreeFormDragDropManager.cs
- Options.cs
- HttpPostedFileBase.cs
- SerializationEventsCache.cs
- UInt32.cs
- DictionaryTraceRecord.cs
- dataprotectionpermission.cs
- ZipPackagePart.cs
- XamlRtfConverter.cs
- RequestedSignatureDialog.cs
- WebControlToolBoxItem.cs
- XmlCDATASection.cs
- XmlTextEncoder.cs
- RawKeyboardInputReport.cs
- SqlSupersetValidator.cs
- EventDescriptor.cs
- BufferedStream.cs
- DirectoryNotFoundException.cs
- ADMembershipProvider.cs
- TreeViewImageKeyConverter.cs
- CngAlgorithm.cs
- HttpFormatExtensions.cs
- TextDecorationCollection.cs
- IntegerValidator.cs
- TextReturnReader.cs
- XmlCharCheckingWriter.cs
- ConnectionManagementElementCollection.cs
- DocumentPage.cs
- ImageListUtils.cs
- MaskPropertyEditor.cs
- SettingsPropertyValue.cs
- SecurityUtils.cs
- TouchFrameEventArgs.cs
- RangeValuePattern.cs
- FixedDocumentPaginator.cs
- DecimalKeyFrameCollection.cs
- AttachedProperty.cs
- ContentElement.cs
- DataRow.cs
- ToolstripProfessionalRenderer.cs
- MiniAssembly.cs
- _emptywebproxy.cs
- UserControl.cs
- ColumnCollection.cs
- RectangleConverter.cs
- BaseCollection.cs
- ProcessHostFactoryHelper.cs
- BasePattern.cs