Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / Net / System / Net / Mail / LinkedResourceCollection.cs / 1 / 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
- SqlUserDefinedTypeAttribute.cs
- CombinedTcpChannel.cs
- CompositeScriptReferenceEventArgs.cs
- DescendantQuery.cs
- SchemaImporter.cs
- controlskin.cs
- FrameworkContentElement.cs
- SpnEndpointIdentity.cs
- PrintDocument.cs
- TimeoutConverter.cs
- ThreadAttributes.cs
- ToolStripContentPanelRenderEventArgs.cs
- HtmlToClrEventProxy.cs
- StreamHelper.cs
- StdRegProviderWrapper.cs
- TokenCreationParameter.cs
- HtmlInputButton.cs
- MergablePropertyAttribute.cs
- DayRenderEvent.cs
- ParserHooks.cs
- TargetControlTypeAttribute.cs
- ConfigurationValue.cs
- DataPagerFieldItem.cs
- CallbackValidator.cs
- CfgSemanticTag.cs
- HostingEnvironmentException.cs
- WebCategoryAttribute.cs
- SQLInt64Storage.cs
- TogglePatternIdentifiers.cs
- IDataContractSurrogate.cs
- SchemaManager.cs
- HttpServerVarsCollection.cs
- ProxyGenerationError.cs
- DefaultShape.cs
- ExternalException.cs
- Literal.cs
- CacheVirtualItemsEvent.cs
- ScrollProviderWrapper.cs
- WebBodyFormatMessageProperty.cs
- SystemSounds.cs
- BatchWriter.cs
- InputScopeConverter.cs
- ProjectionCamera.cs
- PrintController.cs
- AttributeCallbackBuilder.cs
- EntityKey.cs
- ContainerParaClient.cs
- CultureInfo.cs
- Stroke.cs
- TaiwanLunisolarCalendar.cs
- BuildDependencySet.cs
- InputBuffer.cs
- CodeTypeReferenceCollection.cs
- ConfigXmlCDataSection.cs
- FontEmbeddingManager.cs
- HostingEnvironment.cs
- ThemeInfoAttribute.cs
- ACE.cs
- TableLayoutSettingsTypeConverter.cs
- SQLChars.cs
- DataSourceCache.cs
- FormsAuthenticationModule.cs
- EntityViewGenerator.cs
- EncryptedHeaderXml.cs
- ArgumentOutOfRangeException.cs
- XpsFilter.cs
- InkCanvasSelectionAdorner.cs
- InstanceDescriptor.cs
- AutoFocusStyle.xaml.cs
- ProtocolElement.cs
- Token.cs
- CodeGenerator.cs
- EditorAttribute.cs
- CodeNamespaceImportCollection.cs
- SqlCrossApplyToCrossJoin.cs
- DataBinder.cs
- X509ChainPolicy.cs
- XmlSerializerSection.cs
- AnnotationResource.cs
- LayoutTableCell.cs
- ColorAnimation.cs
- ValueSerializerAttribute.cs
- DrawTreeNodeEventArgs.cs
- DbMetaDataFactory.cs
- ActivityTypeCodeDomSerializer.cs
- XamlTreeBuilderBamlRecordWriter.cs
- ExpandoClass.cs
- StorageRoot.cs
- GroupBoxRenderer.cs
- AuthenticationModeHelper.cs
- Signature.cs
- CachingHintValidation.cs
- XmlSchemaInclude.cs
- _SslStream.cs
- ToolStripSystemRenderer.cs
- XmlDataProvider.cs
- SingleSelectRootGridEntry.cs
- LinqDataView.cs
- UIHelper.cs
- UrlParameterReader.cs