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
- DesignerActionVerbList.cs
- ScriptResourceDefinition.cs
- TextRangeAdaptor.cs
- BinHexDecoder.cs
- XDeferredAxisSource.cs
- RightsManagementManager.cs
- OneOfElement.cs
- SHA1.cs
- HtmlLink.cs
- ThemeDirectoryCompiler.cs
- PhysicalFontFamily.cs
- SqlWriter.cs
- AspNetCacheProfileAttribute.cs
- EventLogger.cs
- XmlSortKey.cs
- UnsafeNativeMethods.cs
- Rss20FeedFormatter.cs
- MemberListBinding.cs
- DirectoryObjectSecurity.cs
- mediaeventargs.cs
- ImageClickEventArgs.cs
- ModifierKeysValueSerializer.cs
- StreamAsIStream.cs
- ProtectedConfigurationSection.cs
- Aggregates.cs
- HostSecurityManager.cs
- DesignerProperties.cs
- ParserContext.cs
- ResourceManager.cs
- CapabilitiesSection.cs
- EventWaitHandle.cs
- DBDataPermissionAttribute.cs
- PackageDigitalSignature.cs
- DataGridViewRow.cs
- ResourcesBuildProvider.cs
- CacheAxisQuery.cs
- CompressionTransform.cs
- IdentityNotMappedException.cs
- ControlValuePropertyAttribute.cs
- DataControlFieldCell.cs
- BamlLocalizableResourceKey.cs
- MediaSystem.cs
- CodeObjectCreateExpression.cs
- FormViewInsertedEventArgs.cs
- GeometryModel3D.cs
- DetailsViewPagerRow.cs
- DropDownButton.cs
- ViewBase.cs
- Light.cs
- QuaternionValueSerializer.cs
- PingOptions.cs
- unsafenativemethodstextservices.cs
- Decoder.cs
- InvariantComparer.cs
- VBIdentifierDesigner.xaml.cs
- MembershipPasswordException.cs
- ConnectionStringsExpressionEditor.cs
- DrawTreeNodeEventArgs.cs
- SrgsElementFactory.cs
- UIElementCollection.cs
- XPathEmptyIterator.cs
- BoundingRectTracker.cs
- FileDialog.cs
- QuaternionIndependentAnimationStorage.cs
- backend.cs
- PreviewPageInfo.cs
- regiisutil.cs
- SByteConverter.cs
- AppSettingsReader.cs
- DbParameterHelper.cs
- StringConverter.cs
- FormsAuthentication.cs
- BuildManagerHost.cs
- DesignerTransactionCloseEvent.cs
- InputScope.cs
- documentsequencetextview.cs
- DesignerSerializationOptionsAttribute.cs
- DataSpaceManager.cs
- HtmlWindow.cs
- PlanCompilerUtil.cs
- CodeAccessPermission.cs
- DataRowExtensions.cs
- SupportsEventValidationAttribute.cs
- SamlAttributeStatement.cs
- DBCSCodePageEncoding.cs
- BinaryWriter.cs
- OleDbConnectionFactory.cs
- Matrix3D.cs
- ContractTypeNameElement.cs
- MouseButtonEventArgs.cs
- RuntimeArgumentHandle.cs
- SqlProfileProvider.cs
- CodeExporter.cs
- DBSqlParserColumn.cs
- BindToObject.cs
- PanelStyle.cs
- AttachedAnnotation.cs
- CorrelationTokenInvalidatedHandler.cs
- TypeNameParser.cs
- FactoryMaker.cs