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
- FixedSOMTableRow.cs
- TheQuery.cs
- XslNumber.cs
- FakeModelItemImpl.cs
- HashAlgorithm.cs
- ColorConvertedBitmap.cs
- DefaultAsyncDataDispatcher.cs
- TagMapCollection.cs
- GeneralTransform2DTo3DTo2D.cs
- FunctionImportMapping.ReturnTypeRenameMapping.cs
- MinimizableAttributeTypeConverter.cs
- CodeIndexerExpression.cs
- ObjectPersistData.cs
- Point3DAnimationBase.cs
- WpfWebRequestHelper.cs
- UserPreferenceChangedEventArgs.cs
- DynamicRenderer.cs
- ExpressionNormalizer.cs
- AssemblyName.cs
- _BasicClient.cs
- AppDomainUnloadedException.cs
- TextPointer.cs
- FtpCachePolicyElement.cs
- DrawingImage.cs
- ProcessManager.cs
- LoginView.cs
- FormViewCommandEventArgs.cs
- ToolStripManager.cs
- FormsAuthenticationTicket.cs
- PkcsUtils.cs
- TripleDES.cs
- SharedPerformanceCounter.cs
- AssertFilter.cs
- ViewSimplifier.cs
- WeakRefEnumerator.cs
- Fonts.cs
- ViewLoader.cs
- DriveNotFoundException.cs
- IFlowDocumentViewer.cs
- CodeDomDecompiler.cs
- ExpressionBinding.cs
- OutputCacheProfileCollection.cs
- _HeaderInfoTable.cs
- SafeCryptoHandles.cs
- PeerNameRecord.cs
- PropertyIdentifier.cs
- MsmqException.cs
- ClientApiGenerator.cs
- ImageAttributes.cs
- PeerNameRecordCollection.cs
- XmlBinaryWriterSession.cs
- Label.cs
- ObjectListGeneralPage.cs
- DataGridViewCellErrorTextNeededEventArgs.cs
- SpoolingTask.cs
- WebPartDisplayModeCollection.cs
- DispatcherExceptionFilterEventArgs.cs
- ConfigXmlText.cs
- WindowsFormsDesignerOptionService.cs
- BufferedGraphics.cs
- BitmapEffectDrawingContextWalker.cs
- Line.cs
- ColorAnimation.cs
- ColumnTypeConverter.cs
- PipelineModuleStepContainer.cs
- ModelPropertyCollectionImpl.cs
- MenuAdapter.cs
- DefaultMemberAttribute.cs
- OleDbDataAdapter.cs
- AncestorChangedEventArgs.cs
- MaskInputRejectedEventArgs.cs
- ProcessModule.cs
- VersionConverter.cs
- SqlTypeSystemProvider.cs
- HitTestParameters.cs
- TheQuery.cs
- DoubleConverter.cs
- MachineKeySection.cs
- DeploymentSectionCache.cs
- DispatchChannelSink.cs
- DataGridViewSelectedCellCollection.cs
- StylusPointPropertyUnit.cs
- BuildDependencySet.cs
- ServiceModelStringsVersion1.cs
- Stacktrace.cs
- IgnoreSection.cs
- DocumentViewerBase.cs
- FieldMetadata.cs
- SystemShuttingDownException.cs
- FamilyMap.cs
- WindowsProgressbar.cs
- Error.cs
- COAUTHIDENTITY.cs
- HScrollProperties.cs
- ResourceDisplayNameAttribute.cs
- OperatingSystem.cs
- AesCryptoServiceProvider.cs
- ClockGroup.cs
- JapaneseCalendar.cs
- ForwardPositionQuery.cs