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
- DPTypeDescriptorContext.cs
- ImageIndexConverter.cs
- TextContainerHelper.cs
- TreePrinter.cs
- Error.cs
- InfoCardRSAOAEPKeyExchangeDeformatter.cs
- BitmapEffectInputData.cs
- UIElementAutomationPeer.cs
- EntityDataSourceContainerNameConverter.cs
- DynamicFilter.cs
- AuthStoreRoleProvider.cs
- BindingOperations.cs
- RequestValidator.cs
- WmlSelectionListAdapter.cs
- PanelDesigner.cs
- Bits.cs
- LayoutEngine.cs
- CommandBindingCollection.cs
- KeySpline.cs
- DataSvcMapFileSerializer.cs
- FixedDocumentPaginator.cs
- ToolboxItemAttribute.cs
- DataListItem.cs
- MyContact.cs
- DBDataPermissionAttribute.cs
- DocumentAutomationPeer.cs
- JsonServiceDocumentSerializer.cs
- QilExpression.cs
- IncrementalReadDecoders.cs
- MulticastNotSupportedException.cs
- ByteStreamMessageEncoder.cs
- InvalidTimeZoneException.cs
- BaseDataList.cs
- SynchronizedDispatch.cs
- RequestCachingSection.cs
- WinEventHandler.cs
- webproxy.cs
- Condition.cs
- GenericXmlSecurityToken.cs
- IntegerValidatorAttribute.cs
- XmlAnyAttributeAttribute.cs
- WorkerRequest.cs
- WindowsRichEditRange.cs
- AudioStateChangedEventArgs.cs
- DataColumn.cs
- ServiceManager.cs
- SecurityAppliedMessage.cs
- TCPClient.cs
- SafeNativeMethods.cs
- unsafenativemethodsother.cs
- MailSettingsSection.cs
- DataGridViewSelectedColumnCollection.cs
- URLString.cs
- figurelengthconverter.cs
- WebPartChrome.cs
- DataMemberFieldConverter.cs
- ChameleonKey.cs
- AcceptorSessionSymmetricTransportSecurityProtocol.cs
- QilList.cs
- AuthenticationConfig.cs
- RawTextInputReport.cs
- SequenceDesigner.xaml.cs
- HitTestParameters3D.cs
- ToolStripItemImageRenderEventArgs.cs
- MobileUserControlDesigner.cs
- ResXDataNode.cs
- CompilationPass2TaskInternal.cs
- DefaultEventAttribute.cs
- EventItfInfo.cs
- InkCollectionBehavior.cs
- UrlMapping.cs
- JsonDeserializer.cs
- Compiler.cs
- SqlCacheDependency.cs
- TableProviderWrapper.cs
- DocumentGridPage.cs
- ComponentEvent.cs
- TypographyProperties.cs
- _HTTPDateParse.cs
- Compiler.cs
- WebPartDeleteVerb.cs
- FormsIdentity.cs
- TextDecorations.cs
- InvalidCastException.cs
- Base64Encoding.cs
- DataSourceXmlSerializer.cs
- UndoManager.cs
- TdsValueSetter.cs
- DataGridLength.cs
- NavigationService.cs
- ListBoxItemWrapperAutomationPeer.cs
- Select.cs
- DesignerAutoFormatStyle.cs
- ImageListUtils.cs
- ToolStripPanelRow.cs
- SimpleExpression.cs
- SmtpClient.cs
- TableLayoutCellPaintEventArgs.cs
- LinqDataSourceUpdateEventArgs.cs
- OleServicesContext.cs