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
- WorkflowFormatterBehavior.cs
- MatrixUtil.cs
- RightsManagementEncryptionTransform.cs
- BitmapCodecInfoInternal.cs
- TransactionFlowOption.cs
- UpdateRecord.cs
- XmlSchemaSimpleTypeRestriction.cs
- RightsManagementEncryptionTransform.cs
- XmlUtf8RawTextWriter.cs
- EndEvent.cs
- StorageBasedPackageProperties.cs
- GuidConverter.cs
- ThreadStateException.cs
- CodeMemberProperty.cs
- WeakHashtable.cs
- TransportElement.cs
- SerialErrors.cs
- PlatformCulture.cs
- QueryOutputWriter.cs
- CategoryValueConverter.cs
- BypassElement.cs
- JoinElimination.cs
- PasswordTextNavigator.cs
- FixedTextView.cs
- EdmSchemaError.cs
- QilNode.cs
- StringSource.cs
- PropertyRef.cs
- DataGridSortCommandEventArgs.cs
- NameValueSectionHandler.cs
- ProcessModelInfo.cs
- XmlSchema.cs
- IdnMapping.cs
- BlockUIContainer.cs
- MetafileHeader.cs
- ArrangedElement.cs
- FormattedTextSymbols.cs
- Color.cs
- RequestQueue.cs
- WorkflowServiceNamespace.cs
- EpmSyndicationContentSerializer.cs
- formatter.cs
- TextElementEnumerator.cs
- UriExt.cs
- FunctionParameter.cs
- MatrixCamera.cs
- NamespaceList.cs
- ListItemCollection.cs
- SpecialFolderEnumConverter.cs
- SecurityPolicySection.cs
- CompilerWrapper.cs
- XmlNodeChangedEventArgs.cs
- WsdlBuildProvider.cs
- Pair.cs
- BitmapImage.cs
- webproxy.cs
- StringUtil.cs
- XMLSyntaxException.cs
- RegexMatchCollection.cs
- AuthenticationModulesSection.cs
- SystemFonts.cs
- ComplexObject.cs
- CaseStatementSlot.cs
- CodeDomSerializationProvider.cs
- ScrollBarAutomationPeer.cs
- InkCollectionBehavior.cs
- GridViewSelectEventArgs.cs
- Int32CAMarshaler.cs
- DataGridDefaultColumnWidthTypeConverter.cs
- SerializationException.cs
- _LocalDataStore.cs
- StringOutput.cs
- Int32Converter.cs
- FontCollection.cs
- cache.cs
- NonBatchDirectoryCompiler.cs
- DefaultValueTypeConverter.cs
- WindowsGrip.cs
- ZoneMembershipCondition.cs
- versioninfo.cs
- TrailingSpaceComparer.cs
- CodeIdentifier.cs
- AppDomain.cs
- entityreference_tresulttype.cs
- wgx_commands.cs
- IdentityHolder.cs
- TextEffectCollection.cs
- BitVector32.cs
- DataChangedEventManager.cs
- FreezableCollection.cs
- PointValueSerializer.cs
- XmlArrayAttribute.cs
- RoutedEventArgs.cs
- MsmqMessage.cs
- DataGridViewAdvancedBorderStyle.cs
- HttpProxyTransportBindingElement.cs
- TagNameToTypeMapper.cs
- ContentValidator.cs
- ContentPlaceHolder.cs
- AdapterDictionary.cs