Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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
- AdapterDictionary.cs
- AnnotationResourceChangedEventArgs.cs
- CodeCompiler.cs
- DetailsViewRowCollection.cs
- CommonObjectSecurity.cs
- PropertyConverter.cs
- ForceCopyBuildProvider.cs
- MobileContainerDesigner.cs
- RepeatButtonAutomationPeer.cs
- Pen.cs
- Bookmark.cs
- TableFieldsEditor.cs
- ParserHooks.cs
- DataGridItemEventArgs.cs
- HashCryptoHandle.cs
- TextEvent.cs
- _BufferOffsetSize.cs
- Utils.cs
- InstanceNotReadyException.cs
- mediaeventargs.cs
- DbProviderServices.cs
- IntSecurity.cs
- dbdatarecord.cs
- EdmToObjectNamespaceMap.cs
- CategoryNameCollection.cs
- ConnectivityStatus.cs
- SqlHelper.cs
- UdpChannelListener.cs
- XmlDocument.cs
- FederatedMessageSecurityOverHttpElement.cs
- ContainerVisual.cs
- Cloud.cs
- ResXResourceSet.cs
- OracleConnectionStringBuilder.cs
- BinaryObjectWriter.cs
- DecoderFallbackWithFailureFlag.cs
- UIEndRequest.cs
- ChtmlTextWriter.cs
- NavigateEvent.cs
- ClientProxyGenerator.cs
- HttpListener.cs
- RadioButtonStandardAdapter.cs
- MarkedHighlightComponent.cs
- FontSource.cs
- RotateTransform.cs
- XmlSchemaExternal.cs
- SiteMapPath.cs
- ListControlConvertEventArgs.cs
- PropertyDescriptorCollection.cs
- DispatcherExceptionFilterEventArgs.cs
- SoapElementAttribute.cs
- RuntimeConfigLKG.cs
- ValueType.cs
- PasswordPropertyTextAttribute.cs
- ConstrainedGroup.cs
- ConfigXmlSignificantWhitespace.cs
- SingleAnimationBase.cs
- ConversionValidationRule.cs
- FlowDocumentScrollViewer.cs
- DataGridViewSortCompareEventArgs.cs
- PrtTicket_Base.cs
- DCSafeHandle.cs
- PrimitiveSchema.cs
- EventPrivateKey.cs
- PeerContact.cs
- HandoffBehavior.cs
- HttpResponseInternalWrapper.cs
- X509Chain.cs
- SynchronizationHandlesCodeDomSerializer.cs
- UnsafeNativeMethodsMilCoreApi.cs
- XmlEncodedRawTextWriter.cs
- ImageListUtils.cs
- SecurityPolicySection.cs
- SystemIPGlobalProperties.cs
- cookie.cs
- FlowPosition.cs
- CodeTypeConstructor.cs
- SafeCoTaskMem.cs
- MenuItemCollection.cs
- MasterPageCodeDomTreeGenerator.cs
- SqlUdtInfo.cs
- PropertyTab.cs
- XmlCustomFormatter.cs
- TimeSpanValidator.cs
- TimeSpanOrInfiniteValidator.cs
- Bits.cs
- StringResourceManager.cs
- PriorityItem.cs
- CacheChildrenQuery.cs
- ApplicationActivator.cs
- DbMetaDataFactory.cs
- CustomValidator.cs
- SortDescriptionCollection.cs
- CanonicalizationDriver.cs
- XhtmlTextWriter.cs
- Int64AnimationUsingKeyFrames.cs
- EndpointDesigner.cs
- IPeerNeighbor.cs
- DataGridTableCollection.cs
- GridView.cs